-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwebpack.config.js
51 lines (47 loc) · 1.44 KB
/
webpack.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
const path=require("path"),
webpack=require("webpack"),
HtmlWebpackPlugin=require("html-webpack-plugin"),
CopyPlugin = require("copy-webpack-plugin");
module.exports=function(env,argv){
const IS_DEV=argv.mode === 'development'; //开发环境
var config={
entry:"./src/main.ts",
output:{
path:path.resolve(__dirname,"dist"),
filename:"js/[name].[fullhash:6].js"
},
module:{
rules:[
{
test:/\.ts$/,
exclude: /node_modules/,
use:"ts-loader"
}
]
},
resolve:{
extensions:['.ts', '.js', '.json']
},
plugins:[
new webpack.DefinePlugin({
"$IS_DEV":JSON.stringify(IS_DEV) //是否是开发环境
}),
new HtmlWebpackPlugin({
template:"src/index.html",
inject:"body",
}),
new CopyPlugin({
patterns: [
{ from: "statics", to: "./statics" },
// {from: "src/.manifest",to: "./.manifest"}
],
}),
],
devServer:{
contentBase:"./dist",
inline:true,
open:true
}
};
return config;
};