-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
56 lines (51 loc) · 1.86 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*global module, process*/
/*eslint no-use-before-define:0 */
var webpack = require('webpack');
var webpackDevServer = require('webpack-dev-server');
var path = require('path');
// Support for extra commandline arguments
var argv = require('optimist')
//--env=XXX: sets a global ENV variable (i.e. window.ENV='XXX')
.alias('e','env').default('e','dev')
.argv;
var config = {
context: path.join(__dirname, 'src'),
entry: {'bundle': './main'},
output:{
path: path.join(__dirname, 'dist'),
filename: '[name].js',
publicPath: isDevServer() ? '/' : ''
},
devServer: {
publicPath: '/'
},
reload: isDevServer() ? 'localhost' : null,
module:{
loaders:[
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.css$/, loader: 'style-loader!css-loader' },
{ test: /\.less$/, loader: 'style-loader!css-loader!less-loader' },
{ test: /\.(png|jpg|gif)$/, loader: 'url-loader?limit=5000&name=[path][name].[ext]&context=./src' },
{ test: /\.eot$/, loader: 'file-loader?name=[path][name].[ext]&context=./src' },
{ test: /\.ttf$/, loader: 'file-loader?name=[path][name].[ext]&context=./src' },
{ test: /\.svg$/, loader: 'file-loader?name=[path][name].[ext]&context=./src' },
{ test: /\.woff$/, loader: 'file-loader?name=[path][name].[ext]&context=./src' },
{ test: /index\.html$/, loader: 'file-loader?name=[path][name].[ext]&context=./src' }
]
},
resolve: {
alias: {
'famous-flex': 'famous-flex/src'
}
},
plugins:[
new webpack.DefinePlugin({
VERSION: JSON.stringify(require('./package.json').version),
ENV: JSON.stringify(argv.env)
})
]
};
function isDevServer() {
return process.argv.join('').indexOf('webpack-dev-server') > -1;
}
module.exports = config;