-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwebpack.config.js
92 lines (81 loc) · 2.46 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
81
82
83
84
85
86
87
88
89
90
91
92
var webpack = require('./node_modules/webpack');
var BundleTracker = require('webpack-bundle-tracker');
var path = require('path');
var ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin');
module.exports = {
context: __dirname,
entry: {
dashboard: ['babel-polyfill', path.resolve('dashboard/static/js')],
pss: ['babel-polyfill', path.resolve('pss/static/js') ],
},
output: {
path: path.resolve("static/bundles"),
publicPath: '/static/bundles/',
filename: '[name]-[hash].js'
},
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all',
},
commons: {
name: "commons",
chunks: "initial",
minChunks: 2
}
}
}
},
module: {
rules: [
{ test: /\.html?$/, loader: ["html-loader"] },
{
test: /\.css?$/,
loaders: ["style-loader", "css-loader"]
},
{
test: /\.scss?$/,
use : [
{ loader: "style-loader" },
{ loader: "css-loader" },
{ loader: "sass-loader"}
]
},
{
test: /\.js?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
use: [
'url-loader?limit=10000',
'img-loader'
]
},
{
test: /\.(png|woff|woff2|eot|ttf|svg|json)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader?limit=100000&name=../fonts/[hash].[ext]'
}
]
},
resolve: {
modules: ['node_modules']
},
plugins: [
// replace moment require with empty module
new ContextReplacementPlugin(/\.\/locale$/, 'empty-module', false, /js$/),
new BundleTracker({filename: './webpack-stats.json'}),
// provide global plugins (EG jquery, lodash)
new webpack.ProvidePlugin({
jQuery: 'jquery',
$: 'jquery',
jquery: 'jquery',
}),
]
};