-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.base.js
108 lines (106 loc) · 2.95 KB
/
webpack.config.base.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
101
102
103
104
105
106
107
108
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const publicPath = '/';
module.exports = {
entry: path.resolve(__dirname, 'src', 'index.js'),
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
publicPath,
chunkFilename: '[chunkhash].async.js',
},
resolve: {
alias: {
'@components': path.resolve(__dirname, 'src', 'components'),
'@pages': path.resolve(__dirname, 'src', 'pages'),
'@utils': path.resolve(__dirname, 'src', 'utils'),
'@primaryTool': path.resolve(__dirname, 'primaryTool'),
'@models': path.resolve(__dirname, 'src', 'models'),
'@routes': path.resolve(__dirname, 'src', 'routes'),
'@services': path.resolve(__dirname, 'src', 'services'),
'@src': path.resolve(__dirname, 'src'),
'@root': path.resolve(__dirname),
},
},
module: {
rules: [
{
test: /\.js$/,
include: [path.resolve(__dirname, 'src'), path.resolve(__dirname, 'primaryTool')],
exclude: [],
loader: 'babel-loader?cacheDirectory',
},
{
test: /\.scss$/,
use: ['style-loader', 'css-loader?modules&localIdentName=__[name]-[local]-[hash:5]__', 'sass-loader'],
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 1,
},
},
],
},
{
test: /\.(ttf|eot|svg|woff|woff2|png|svg|jpg|gif)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
},
},
],
},
],
},
externals: {},
node: {
fs: 'empty',
module: 'empty',
},
// devtool: 'source-map',
devtool: 'hidden-source-map',
optimization: {
splitChunks: {
cacheGroups: {
styles: {
name: 'styles',
test: /\.(css|less)/,
chunks: 'all',
enforce: true,
},
},
},
},
plugins: [
new ProgressBarPlugin(),
new FriendlyErrorsWebpackPlugin(),
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css',
}),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'src', 'index.ejs'),
filename: 'index.html',
hash: true,
}),
new webpack.HotModuleReplacementPlugin(),
new ManifestPlugin(),
new webpack.DefinePlugin({
'process.env': {
APP_ENV: JSON.stringify(process.env.APP_ENV),
},
}),
],
};