forked from gbozee/pyconng
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathwebpack.config.js
80 lines (77 loc) · 2.32 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import path from 'path';
import webpack from 'webpack';
import ForceCaseSensitivityPlugin from 'force-case-sensitivity-webpack-plugin';
import BundleTracker from 'webpack-bundle-tracker';
module.exports = () => {
const NODE_ENV = process.env.NODE_ENV;
let plugins = [
// add all common plugins here
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(NODE_ENV),
},
}),
// Promise and fetch polyfills
new webpack.ProvidePlugin({
// Promise: 'imports?this=>global!exports?global.Promise!es6-promise',
// fetch: 'imports?this=>global!exports?global.fetch!whatwg-fetch',
$: 'jquery',
jQuery: 'jquery',
'windows.jQuery': 'jquery',
}),
new BundleTracker({filename: './webpack-stats.json'}),
new ForceCaseSensitivityPlugin(), // OSX wont check but other unix os will
new webpack.NoErrorsPlugin(),
];
if (NODE_ENV !== 'test') {
// karma webpack can't use these
plugins = [
...plugins,
// vendor chuncks
// new webpack.optimize.CommonsChunkPlugin({
// name: 'vendor',
// minChunks: Infinity,
// filename: 'vendor-[hash].js',
// }),
// // shared stuff between chuncks
// new webpack.optimize.CommonsChunkPlugin({
// name: 'common',
// filename: 'common-[hash].js',
// chunks: [], // add common modules here
// }),
];
}
return {
devtool: 'inline-source-map',
entry: './src/main.js',
output: {
path: __dirname + '/static/js',
publicPath: 'http://localhost:8080/bundles/',
filename: 'bundle.js',
},
plugins,
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ['babel-loader'],
},
// {test: /\.scss$/, loader: 'style-loader!css-loader!sass-loader'},
// {test: /\.css$/, loader: 'style-loader!css-loader'},
// {test: /\.(png|jpg|gif)$/, loader: 'url-loader', query: {limit: 8192}}, // inline base64 URLs <=8k
// {test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'file-loader'},
], // add all common loaders here
},
resolve: {
extensions: ['', '.js', '.jsx'],
modules: [
'node_modules',
'bower_components',
],
},
externals: {
'jquery': 'jQuery',
},
};
};