-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.common.config.js
169 lines (157 loc) · 3.53 KB
/
webpack.common.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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/**
* @File : webpack.dev.config.js
* @Author : dtysky ([email protected])
* @Date : Wed Jul 24 2019
* @Description:
*/
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const Publisher = require('@alipay/seinjs-alipay-cdn-publisher');
const SeinJSPlatformPlugin = require('./webpack-platform-plugin/lib/index');
const Platform = process.env.SIENJS_PLATFORM;
const Mode = process.env.NODE_ENV;
const isDev = Mode !== 'production';
const outPath = path.resolve(__dirname, `./${Platform}/sein-game`);
const publisher = new Publisher({
// 必选,资源仓库前缀,建议项目名
prefix: 'seinjs-tiny-program',
// 可选,发布到内网还是公网,默认内网
// 内网为`internal`,公网为`public`
mode: 'public',
// forMyTinyProgram: true
});
console.log(Platform, Mode);
module.exports = {
mode: Mode,
devtool: 'none',
output: {
path: outPath,
filename: '[name].js',
chunkFilename: '[name].js',
publicPath: '/sein-game/',
libraryTarget: 'commonjs2'
},
resolve: {
extensions: [".ts", ".tsx", ".js"],
alias: {
'seinjs-tiny-program-hud': path.resolve(__dirname, './tiny-program-hud/src')
}
},
externals: {
'fs': true,
'path': true,
},
module: {
rules: [
{
enforce: 'pre',
test: /\.tsx?$/,
use: [
{
loader: "awesome-typescript-loader"
},
{
loader: 'tslint-loader',
query: {
configFile: path.resolve(__dirname, './tslintConfig.js')
}
}
],
exclude: /node_modules/
},
{
test: /\.md$/,
use: [
{
loader: 'raw-loader'
}
]
},
{
test: /\.(png|jpg|gif|svg|mp4)$/,
use: {
loader: 'seinjs-url-loader',
options: {
base64: {
enabled: false
},
publish: {
enabled: true,
excludes: [],
publisher
}
}
}
},
{
test: /\.(gltf|glb)$/,
use: {
loader: 'seinjs-gltf-loader',
options: {
compress: {
enabled: true
},
glb: {
enabled: false
},
base64: {
enabled: false
},
publish: {
enabled: true,
excludes: [],
publisher
}
}
}
},
{
test: /\.atlas$/,
use: {
loader: 'seinjs-atlas-loader',
options: {
base64: {
enabled: false
},
publish: {
enabled: true,
excludes: [],
publisher
}
}
}
}
]
},
optimization: {
splitChunks: {
minChunks: 1,
cacheGroups: {
seinjs: {
name: 'seinjs',
chunks: 'initial',
test: m => {
if (m.external) {
return false;
}
return m.rawRequest === 'seinjs' || m.rawRequest === 'seinjs-orig';
},
priority: 2
},
common: {
name: 'common',
chunks: 'initial',
test: /(node_modules|utils)/,
priority: 1
}
}
}
},
plugins: [
new CleanWebpackPlugin(
['*'],
{root: outPath}
),
new SeinJSPlatformPlugin({platform: Platform})
]
};