forked from thewillhuang/webpack-code-splitting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.base.config.babel.js
100 lines (96 loc) · 2.13 KB
/
webpack.base.config.babel.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
90
91
92
93
94
95
96
97
98
99
100
import path from 'path';
import webpack from 'webpack';
import autoprefixer from 'autoprefixer';
import ForceCaseSensitivity from 'case-sensitive-paths-webpack-plugin';
import HtmlPlugin from 'html-webpack-plugin';
export const PostCSS = {
loader: 'postcss-loader',
options: {
plugins() {
return [
autoprefixer({ browsers: 'last 2 versions' }),
];
},
},
};
export const CSSLoaderConfig = production => ({
loader: 'css-loader',
options: {
modules: true,
importLoaders: 1,
localIdentName: production ? '[sha512:hash:base64:8]' : '[path]___[name]__[local]___[hash:base64:5]',
},
});
export const babelConfig = {
loader: 'babel-loader',
options: {
babelrc: false,
plugins: ['transform-runtime'],
presets: [
['env', {
targets: {
uglify: true,
},
modules: false,
}],
'stage-0',
'react',
],
},
};
export default {
entry: {
app1: ['./packages/app1'],
app2: ['./packages/app2'],
app3: ['./packages/app3'],
app4: ['./packages/app4'],
app5: ['./packages/app5'],
app6: ['./packages/app6'],
app7: ['./packages/app7'],
app8: ['./packages/app8'],
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: [babelConfig],
},
{
test: /\.scss$/,
include: /node_modules/,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
{
test: /\.css$/,
include: /node_modules/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(eot|ttf|woff|woff2)$/,
loader: 'url-loader',
options: {
limit: 10000,
name: '[sha512:hash:base64:7].[ext]',
},
}],
},
output: {
path: path.resolve('./dist'),
},
plugins: [
new ForceCaseSensitivity(),
new webpack.NoEmitOnErrorsPlugin(),
new HtmlPlugin({
inject: true,
template: './template.ejs',
minify: {
removeAttributeQuotes: true,
collapseWhitespace: true,
},
}),
],
resolve: {
extensions: ['.js', '.jsx', '.json', '.css', '.scss'],
},
};