-
Notifications
You must be signed in to change notification settings - Fork 6
/
webpack.config.js
67 lines (65 loc) · 1.58 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
64
65
66
67
// Generated using webpack-cli https://github.com/webpack/webpack-cli
// http://auto.moly.host/index.html#/template/template
const path = require("path");
const webpack = require("webpack");
const AutojsDeployPlugin = require("./autojs-deploy");
const babelConfig = require("./babel.config");
const config = {
entry: {
main: "./src/miui_cleaner_app/index.js",
services: "./src/miui_cleaner_app/services.js",
},
output: {
path: path.resolve(__dirname, "dist/miui_cleaner_app"),
filename: "[name].js",
clean: true,
},
target: "node",
plugins: [
new AutojsDeployPlugin({
// {boolean|String|boolean[]|String[]} 添加`"ui";`前缀的chunk(output)名单,true代表project.json中定义的main,字符串代表文件名
// {String} 必须的 project.json 的文件路径
configFile: path.resolve(__dirname, "src/miui_cleaner_app/project.json"),
}),
],
module: {
rules: [
{
test: /\.(js|jsx)$/i,
use: [
{
loader: "babel-loader",
options: babelConfig,
},
],
},
{
test: /\.(png|svg|jpg|gif)$/,
use: {
loader: "url-loader",
},
},
],
},
};
module.exports = (env, args) => {
const isProduction = args.mode ? args.mode === "production" : env.WEBPACK_BUILD;
if (isProduction) {
config.mode = "production";
config.devtool = false;
config.plugins.push(
new webpack.DefinePlugin({
DEBUG: JSON.stringify(false),
}),
);
} else {
config.mode = "development";
config.devtool = "source-map";
config.plugins.push(
new webpack.DefinePlugin({
DEBUG: JSON.stringify(true),
}),
);
}
return config;
};