-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.dev.js
executable file
·87 lines (83 loc) · 2.01 KB
/
webpack.config.dev.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
/**
* webpack config development
* @auther:jaden_wong@icloud.com
* @update:2019-5-12
*/
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require(`html-webpack-plugin`);
const miniCSSExtractPlugin = require('mini-css-extract-plugin');
const webpackDevConfig = {
mode: 'development',
target: 'web',
entry: {
home: ['./src/page/home/index.js'],
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'assets/js/[name].[hash].js',
},
devtool: 'inline-source-map',
devServer: {
contentBase: path.join(__dirname, 'dist'),
compress: true,
inline: true,
hot: true,
port: 1314,
quiet: false,
},
module: {
rules: [
{
test: /\.(less|css)$/,
use: [
{
loader: 'style-loader',
},
{
loader: miniCSSExtractPlugin.loader,
},
{
loader: 'css-loader',
},
{
loader: 'postcss-loader',
},
{ loader: 'less-loader' },
],
},
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/, // 要排除node_modules,bower_components下的JS文件
loader: 'babel-loader',
},
],
},
plugins: [
new webpack.NamedModulesPlugin(),
new miniCSSExtractPlugin({
filename: './assets/css/[name].css',
chunkFilename: './assets/css/[id].css',
}),
new HtmlWebpackPlugin({
filename: 'page/home/index.html',
template: './src/page/home/index.ejs',
inject: true,
chunks: ['home', 'homeTY'],
minify: false,
cdn: {
js: [
`https://cdn.bootcss.com/vConsole/3.3.0/vconsole.min.js`,
],
},
}),
],
};
console.log(
'============================webpack env begin=============================='
);
console.log('webpack env:', process.env.NODE_ENV);
console.log(
'============================webpack env end================================'
);
module.exports = webpackDevConfig;