2021-04-04 20:48:18 +08:00
|
|
|
const Copy = require("./plugins/copy");
|
2021-04-05 11:10:54 +08:00
|
|
|
const Path = require("path");
|
2021-11-10 22:05:15 +08:00
|
|
|
const TerserPlugin = require("terser-webpack-plugin");
|
|
|
|
console.log("***env: ", process.env.NODE_ENV);
|
|
|
|
let configureWebpack = {};
|
|
|
|
switch (process.env.NODE_ENV) {
|
|
|
|
case "development": {
|
|
|
|
configureWebpack = {
|
|
|
|
mode: "development",
|
|
|
|
devtool: "#source-map",
|
|
|
|
};
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "production": {
|
|
|
|
configureWebpack = {
|
|
|
|
mode: "production",
|
|
|
|
optimization: {
|
|
|
|
minimizer: [
|
|
|
|
new TerserPlugin({
|
|
|
|
terserOptions: {
|
|
|
|
compress: {
|
|
|
|
drop_console: true, // 移除console
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-02 21:49:55 +08:00
|
|
|
module.exports = {
|
|
|
|
publicPath: "/",
|
|
|
|
outputDir: "dist",
|
|
|
|
pages: {
|
2021-04-03 16:47:16 +08:00
|
|
|
popup: "src/popup/index.ts",
|
2021-04-02 21:49:55 +08:00
|
|
|
options: "src/options/index.ts",
|
2021-04-03 16:47:16 +08:00
|
|
|
devtools: "src/devtools/index.ts",
|
2021-04-02 21:49:55 +08:00
|
|
|
},
|
2021-04-03 16:14:37 +08:00
|
|
|
pluginOptions: {
|
|
|
|
browserExtension: {
|
|
|
|
components: {
|
|
|
|
background: true,
|
|
|
|
contentScripts: true,
|
|
|
|
},
|
|
|
|
componentOptions: {
|
|
|
|
contentScripts: {
|
|
|
|
entries: {
|
2021-04-04 20:48:18 +08:00
|
|
|
content: "src/content.ts",
|
2021-11-04 22:22:11 +08:00
|
|
|
inject: "src/inject/index.ts",
|
2021-04-03 16:14:37 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
background: {
|
|
|
|
entry: "src/background.ts",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-11-10 22:05:15 +08:00
|
|
|
configureWebpack,
|
2021-04-02 21:49:55 +08:00
|
|
|
};
|