-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.production.config.js
64 lines (61 loc) · 1.78 KB
/
webpack.production.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
var Webpack = require('webpack'),
path = require('path'),
util = require('util'),
pkg = require('./package.json'),
ExtractTextPlugin = require('extract-text-webpack-plugin');
var nodeModulesPath = path.resolve(__dirname, 'node_modules'),
mainPath = path.resolve(__dirname, 'src', 'app.js'),
buildPath = path.resolve(__dirname, 'dist'),
cssBundleName = util.format('style.bundle.%s.css', pkg.version),
jsBundleName = util.format('js/app.bundle.%s.js', pkg.version);
var config = {
devtool: 'source-map',
entry: {
app: [mainPath]
},
output: {
path: buildPath,
filename: jsBundleName
},
module: {
loaders: [
{
test: /\.js(x)?$/,
loader: 'babel',
exclude: nodeModulesPath
},
{
test: /\.(css|scss)$/,
loader: ExtractTextPlugin.extract('css?sourceMap!sass?sourceMap')
},
{
test: /\.(png|jpg|jpeg|gif)$/,
loader: 'url?limit=8192&name=assets/images/[name].[ext]'
},
{
test : /\.(woff|woff2|ttf|eot|svg)$/,
loader: 'url?limit=8192&name=assets/fonts/[name].[ext]'
}
]
},
plugins: [
new ExtractTextPlugin(cssBundleName, {
allChunks: true
}),
new Webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
'root.jQuery': 'jquery'
}),
new Webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
],
resolve: {
extensions: ['', '.js', '.jsx', '.css', '.scss']
}
};
module.exports = config;