-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
89 lines (88 loc) · 2.42 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
const path = require('path');
const webpack = require("webpack")
const plugins = require('./plugins').plugins
const env = process.env || 'dev';
const isProd = env === 'prod';
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const config = {
context: path.resolve('src'),
entry: {
bundle: ["./js/app.jsx"],
vendor: [
'react',
'react-dom',
'react-redux',
'react-router',
'redux',
'redux-saga',
'lodash',
'prop-types',
'react-loader',
'react-router-dom'
]
},
output: {
path: path.resolve('build/'),
publicPath: '/',
filename: "[name].[hash].js",
//chunkFilename: '[name].[chunkhash].js'
},
devServer: {
historyApiFallback: true,
contentBase: path.join(__dirname, 'src','html'),
hot: true,
inline: true
},
devtool: isProd ? 'source-map' : 'cheap-module-source-map',
stats: {
colors: true,
reasons: true,
chunks: true
},
module: {
rules: [{
test: [/\.js$/, /\.jsx$/],
exclude: /(node_modules)/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react']
}
},
{
test: /\.css$/,
exclude: /(node_modules)/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
//resolve-url-loader may be chained before sass-loader if necessary
use: 'css-loader'
})
},
{
test: /\.less$/,
exclude: /(node_modules)/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
//resolve-url-loader may be chained before less-loader if necessary
use: ['css-loader', 'less-loader?relativeUrls&noIeCompat']
})
},
{
test: /\.(png|jpg|gif|json)$/,
use: [
{
loader: 'file-loader',
options: {}
}
]
}
]
},
resolve: {
extensions: ['.jsx', '.js', '.es6']
},
plugins: plugins,
}
if (isProd) {
config.entry.unshift('webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000', 'webpack/hot/only-dev-server');
}
module.exports = config