-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
82 lines (82 loc) · 2.31 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
// webpack.config.js
const webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin"); // allows to extract the generated css out of the bundle
const extractLess = new ExtractTextPlugin("dist/[name].css");
module.exports = {
devServer: {
// overlay: true is equivalent
overlay: {
errors: true,
warnings: true,
},
historyApiFallback: true
},
entry: {
"vendor": [
"expose-loader?React!react",
"expose-loader?ReactDOM!react-dom",
"expose-loader?moment!moment",
],
index: './src/js/index.js',
common: './src/js/common.js',
},
output: {
filename: 'dist/[name].js',
chunkFilename: "dist/[id].bundle.js"
},
module: {
rules: [
{
enforce: "pre",
test: /\.js$/,
exclude: /node_modules/,
use: 'eslint-loader',
},
{
test: /\.js$|\.jsx$/,
exclude: /node_modules/,
use: 'babel-loader'
},
{
test: /\.css$/,
exclude: /node_modules/,
use: extractLess.extract({
use: ["css-loader"],
// use style-loader in development
fallback: "style-loader"
})
},
{
test: /\.less$/,
exclude: /node_modules/,
use: extractLess.extract({
use: [ "css-loader", "less-loader"],
// use style-loader in development
fallback: "style-loader"
})
},
{
test: /\.svg$/,
use: 'svg-url-loader'
}
],
},
externals: {
// Use external version of React
"react": "React",
"react-dom": "ReactDOM",
"moment": "moment"
},
// Use the plugin to specify the resulting filename (and add needed behavior to the compiler)
plugins: [
extractLess,
new webpack.optimize.CommonsChunkPlugin({
name: "vendor",
minChunks: Infinity,
async: true
})
],
resolve: {
extensions: ['.js', '.jsx']
}
};