-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
63 lines (57 loc) · 1.68 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
52
53
54
55
56
57
58
59
60
61
62
63
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = env => {
if (!env) {
env = {};
}
let config ={
entry: "./src/game.ts",
output: {
path: __dirname + "/dist",//打包后的文件存放的地方
filename: "game.js"//打包后输出文件的文件名
},
devtool: 'source-map',
devServer: {
contentBase: "./dist",//本地服务器所加载的页面所在的目录
historyApiFallback: true,//不跳转
inline: true//实时刷新
},
resolve:{
extensions: ['.ts', '.js'],
symlinks: false
},
module: {
rules: [
// {
// test: /(\.jsx|\.js)$/,
// use: {
// loader: "babel-loader",
// },
// exclude: /node_modules/
// },
{
test: /\.tsx?$/,
use: {
loader: "ts-loader",
},
exclude: /node_modules/
}
]
},
plugins:[
new webpack.DefinePlugin({
'IS_WX': JSON.stringify(!!env.wx)
}),
new CopyWebpackPlugin([
'game.json',
'project.config.json',
{from:'src/openDataContext',to:'openDataContext'}
])
]
}
if(!env.wx){
config.plugins.push(new HtmlWebpackPlugin())
}
return config
}