-
Notifications
You must be signed in to change notification settings - Fork 49
/
vue.config.js
78 lines (68 loc) · 2.01 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
74
75
76
77
78
const CopyWebpackPlugin = require("copy-webpack-plugin");
const path = require("path");
const GenerateJsonFromJsPlugin = require("generate-json-from-js-webpack-plugin");
const webpack = require('webpack');
process.env.VUE_APP_VERSION = process.env.npm_package_version;
const outputDir = process.env.NODE_ENV === "production" ? ".build" : "dist";
const productionSourceMap =
process.env.NODE_ENV === "production" ? false : true;
// Generate pages object
const pages = {};
const chromeName = process.env.VUE_APP_FILE.split(",");
chromeName.forEach((name) => {
pages[name] = {
entry: `src/entry/${name}.ts`,
template: "public/index.html",
filename: `${name}.html`,
};
});
const hotReload = {
from: path.resolve(`src/hot-reload.js`),
to: `${path.resolve(outputDir)}/hot-reload.js`,
};
const toCopy = [
// {
// from: path.resolve(`src/manifest.${process.env.NODE_ENV}.json`),
// to: `${path.resolve(outputDir)}/manifest.json`,
// },
{
from: path.resolve(
`src/service-worker.${
process.env.NODE_ENV === "development" ? "development" : "production"
}.js`
),
to: `${path.resolve(outputDir)}/service-worker.js`,
},
{
from: path.resolve(`icons/*`),
to: `${path.resolve(outputDir)}`,
},
];
if (process.env.NODE_ENV === "development") {
toCopy.push(hotReload);
}
module.exports = {
pages,
filenameHashing: false,
outputDir: outputDir,
productionSourceMap: productionSourceMap,
configureWebpack: {
devtool: "cheap-module-source-map",
plugins: [
new webpack.DefinePlugin({
// Vue CLI is in maintenance mode, and probably won't merge my PR to fix this in their tooling
// https://github.com/vuejs/vue-cli/pull/7443
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false',
}),
CopyWebpackPlugin(toCopy),
new GenerateJsonFromJsPlugin({
path: "./src/manifest.js",
filename: "manifest.json",
}),
],
output: {
filename: `js/[name].js`,
chunkFilename: `[name].js`,
},
},
};