代码拉取完成,页面将自动刷新
const CopyWebpackPlugin = require("copy-webpack-plugin");
const path = require("path");
const packageName = "dist" // 定义项目打包后文件名
const ExtensionReloader = require('webpack-extension-reloader');
// 复制文件夹到指定目录
const copyFiles = [
{
from: path.resolve("src/manifest.json"),
to: `${path.resolve(packageName)}/manifest.json`
},
{
from: path.resolve("src/assets"),
to: path.resolve(packageName)
},
{
from: path.resolve("src/_locales"),
to: path.resolve(packageName + "/_locales")
}
];
// 复制插件
const plugins = [
new CopyWebpackPlugin({
patterns: copyFiles
}),
new ExtensionReloader({
reloadPage: true,
}),
];
module.exports = {
pages: {
popup: {
entry: `src/popup/main.js`,
template: `src/popup/index.html`,
filename: `popup.html`
}
},
productionSourceMap: false,
pluginOptions: {
browserExtension: {
componentOptions: {
background: {
entry: 'src/background/main.js'
},
contentScripts: {
entries: {
'content-script': [
'src/content-scripts/main.js'
]
}
}
}
}
},
// 根目录 如果不写 默认是dist
outputDir: __dirname + '/' + packageName,
configureWebpack: {
watch: true, // 自动打包
entry: {
content: "./src/content-scripts/main.js",
background: "./src/background/main.js"
},
output: {
filename: "js/[name].js"
},
plugins,
optimization: {
splitChunks: false,
},
// 打包文件大小配置
performance: {
maxEntrypointSize: 10000000,
maxAssetSize: 30000000
}
},
css: {
extract: {
filename: "css/[name].css"
}
},
chainWebpack: config => {
if (process.env.NODE_ENV === 'production') {
config.output.filename('js/[name].js').end()
config.output.chunkFilename('js/[name].js').end()
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。