-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.base.config.js
85 lines (81 loc) · 2.7 KB
/
webpack.base.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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
commonConfig = {
entry: {
app: [
path.join(__dirname, 'src/index.js')
],
vendor: ['react', 'react-router-dom','mobx' ,'react-dom', 'mobx-react']//分离第三方库,可自定义增加
},
output: {
path: path.join(__dirname, './dist'),
filename: '[name].[chunkhash].js',
chunkFilename: '[name].[chunkhash].js',
publicPath: "/"
},
module: {
rules: [{
test: /\.js$/,
use: ['babel-loader?cacheDirectory=true'],
include: path.join(__dirname, 'src')
}, {
test: /\.(png|jpg|gif|ico|jpeg|bmp)$/,
use: [{
loader: 'url-loader',
options: {
limit: 8192
}
}]
}, {
test: /\.less$/,
use: [
'style-loader',
{ loader: 'css-loader', options: { importLoaders: 1 } },
'postcss-loader',
{loader:'less-loader', options: {
modifyVars: {
//http://ip/iconfont
// '@icon-url': '"/fonts/iconfont/iconfont"',
// "@primary-color": "#7bceda"
}
}}
]
}, {
test: /\.scss$/,
use: [
{ loader: 'style-loader', options: { sourceMap: true }},
{ loader: 'css-loader', options: { sourceMap: true}},
{ loader: 'postcss-loader', options: { sourceMap: true }},
{ loader: 'sass-loader', options: { sourceMap: true }}
]
}]
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
favicon: 'src/assets/favicon.ico',
template: path.join(__dirname, 'src/index.html')
}),
new webpack.HashedModuleIdsPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor'
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'runtime'
})
],
resolve: {
alias: {
'@' : path.join(__dirname, 'src'),
'assets': path.join(__dirname, 'src/assets'),
'pages': path.join(__dirname, 'src/pages'),
'components': path.join(__dirname, 'src/components'),
'router': path.join(__dirname, 'src/router'),
'stores': path.join(__dirname, 'src/stores')
},
modules: [path.join(__dirname, 'src'), 'node_modules'],
extensions: [".js", ".jsx"]
},
};
module.exports = commonConfig;