-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
56 lines (52 loc) · 1.37 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
/* eslint-env node */
const path = require('path');
var webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
// A list of 3rd party packages to be bundled separately for caching purposes.
// Example: [ 'react', 'lodash', 'redux', 'react-redux', 'react-dom' ]
const VENDOR_LIBS = []
const config = {
entry: {
bundle: './src/index.js'
},
output: {
path: path.join(__dirname, 'build'),
filename: '[name].[chunkhash].js'
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: 'babel-loader'
}, {
use: ExtractTextPlugin.extract({use: 'css-loader!postcss-loader'}),
test: /\.css$/
}, {
test: /\.(jpe?g|png|gif|svg)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 40000
}
},
'image-webpack-loader'
]
}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
names: ['vendor', 'manifest']
}),
new ExtractTextPlugin('style.[chunkhash].css'),
new HtmlWebpackPlugin({template: 'src/index.html'})
]
};
// Add VENDOR_LIBS to config.entry.vendor if it contains packages
if (VENDOR_LIBS.length) {
config.entry.vendor = VENDOR_LIBS;
}
module.exports = config;