-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.dev.conf.js
More file actions
88 lines (81 loc) · 2.42 KB
/
Copy pathwebpack.dev.conf.js
File metadata and controls
88 lines (81 loc) · 2.42 KB
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
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
module.exports = {
devtool: 'inline-source-map',
// 入口文件
entry: [
path.resolve(__dirname, "src/index.js")
],
// 输出文件路径
output: {
path: path.resolve(__dirname, "./dist"),
filename: "[name].[hash:8].bundle.js"
},
// babel解析
module: {
rules: [
{
test: /\.js$/,
use: ["babel-loader?cacheDirectory=true"],
include: path.join(__dirname, 'src')
},
{
test: /\.(png|jpeg|jpg|gif)$/,
use: [
{
loader: "url-loader",
options: {
limit: 8192
}
}
]
},
{
test: /\.css$/,
use: ['style-loader', MiniCssExtractPlugin.loader, 'css-loader']
},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader?modules',
'postcss-loader',
'sass-loader',
]
}
]
},
// 别名
resolve: {
alias: {
actions: path.join(__dirname, 'src/actions'),
api: path.join(__dirname, 'src/api'),
components: path.join(__dirname, 'src/components'),
pages: path.join(__dirname, 'src/pages'),
images: path.join(__dirname, 'src/images'),
reducers: path.join(__dirname, 'src/reducers'),
router: path.join(__dirname, 'src/router'),
utils: path.join(__dirname, 'src/utils')
}
},
// 服务器
devServer: {
contentBase: path.join(__dirname, './dist'),
historyApiFallback: true,
host: '192.168.1.31',
port: 8000
},
// 插件
plugins: [
new CleanWebpackPlugin('dist', {}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: path.resolve(__dirname, 'src/index.html')
}),
new MiniCssExtractPlugin({
filename: 'style.[chunkhash:8].css'
})
]
};