-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.base.config.js
73 lines (70 loc) · 1.61 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
// Webpack 基础配置
// 关于更多 Webpack 配置方法,请参考我另一篇文章[《为什么我们要做三份 Webpack 配置文件》](https://zhuanlan.zhihu.com/p/29161762)
const path = require('path');
const webpack = require('webpack');
const SRC_PATH = path.resolve('./src');
const ASSETS_BUILD_PATH = path.resolve('./build');
const ASSETS_PUBLIC_PATH = '/assets/';
module.exports = {
context: SRC_PATH,
entry: {
app: './',
vendor: './vendor',
},
resolve: {
extensions: ['.js', '.jsx']
},
output: {
path: ASSETS_BUILD_PATH,
publicPath: ASSETS_PUBLIC_PATH,
filename: '[name].js'
},
module: {
rules: [
{
enforce: 'pre',
test: /\.jsx?$/,
use: ['eslint-loader'],
exclude: /node_modules/
},
{
test: /\.jsx?$/,
use:
[
{
loader: 'babel-loader',
options: { cacheDirectory: true }
}
],
exclude: /node_modules/
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
include: /node_modules/
},
{
test: /\.less$/,
use:
[
'style-loader',
{
// 启用 CSS 模块化
loader: 'css-loader',
options: {
modules: true,
sourceMap: true,
localIdentName: 'im-[path]-[local]'
}
},
'less-loader'
],
exclude: /node_modules/
}
]
},
plugins: [new webpack.optimize.CommonsChunkPlugin({
names: ['vendor'],
minChunks: Infinity
})]
};