-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
73 lines (69 loc) · 1.99 KB
/
vue.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
const CopyWebpackPlugin = require("copy-webpack-plugin");
const path = require("path");
const { defineConfig } = require("@vue/cli-service");
// 生成manifest文件
const manifest =
process.env.NODE_ENV === "production"
? {
from: path.resolve("src/manifest.production.json"),
to: `${path.resolve("dist")}/manifest.json`,
}
: {
from: path.resolve("src/manifest.development.json"),
to: `${path.resolve("dist")}/manifest.json`,
};
//生成background.js
const bgjs = {
from: path.resolve("src/background.js"),
to: `${path.resolve("dist")}/js/background.js`,
};
//生成content.js
const ctjs = {
from: path.resolve("src/content.js"),
to: `${path.resolve("dist")}/js/content.js`,
};
module.exports = defineConfig({
transpileDependencies: true,
filenameHashing: false, // 为 false 来关闭文件名哈希。
productionSourceMap: false, // 生产环境是否生成 sourceMap 文件
//多页面,popup.html,options.html
pages: {
popup: {
template: "public/index.html",
entry: "./src/popup/main.js",
title: "Popup",
},
options: {
template: "public/index.html",
entry: "./src/options/main.js",
title: "Options",
},
},
chainWebpack: (config) => {
config.plugin("copy").use(CopyWebpackPlugin, [
{
patterns: [
manifest,
bgjs,
ctjs,
{
from: path.resolve("public/icons/"),
to: `${path.resolve("dist")}/icons/`,
},
{
from: path.resolve("public/favicon.ico"),
to: `${path.resolve("dist")}/favicon.ico`,
},
],
},
]);
},
css: {
//输出css
extract: false,
},
});
//屏蔽生成-legacy文件,找到.browserslistrc。后面添加一句话即可 not ie <= 11
//package.json更改为 "serve": "vue-cli-service build --mode development --watch",
//.eslintrc.json 需要添加:"env": {"webextensions": true}
//在manifest中backgroud "persistent": true