-
Notifications
You must be signed in to change notification settings - Fork 6
/
vue.config.js
104 lines (91 loc) · 2.79 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*eslint-env node*/
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
var LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
const PRODUCTION = 'production';
const DEVELOPMENT = 'development';
let mode = process.env['PRODUCTION'] ? PRODUCTION : DEVELOPMENT;
// Cleans up log spam from mini-css-extract-plugin and the like.
// Based on: https://github.com/webpack-contrib/mini-css-extract-plugin/issues/168#issuecomment-420095982
class CleanUpStatsPlugin {
constructor(name) {
this.name = name;
}
shouldPickStatChild(child) {
return child.name.indexOf(this.name) !== 0;
}
apply(compiler) {
compiler.hooks.done.tap('CleanUpStatsPlugin', (stats) => {
const children = stats.compilation.children;
if (Array.isArray(children)) {
// eslint-disable-next-line no-param-reassign
stats.compilation.children = children.filter((child) =>
this.shouldPickStatChild(child)
);
}
});
}
}
/**
* @type {import('@vue/cli-service').ProjectOptions}
*/
module.exports = {
pages: {
dashboard: {
entry: 'src/dashboard/dashboard.js',
},
popup: {
entry: 'src/popup/popup.js',
},
},
configureWebpack: {
devtool: 'source-map',
// Event pages and background/content scripts pages go here
entry: {
background: ['./src/background/background.ts'],
content_youtube: ['./src/content_scripts/content_youtube.js'],
content_medium: ['./src/content_scripts/content_medium.js'],
},
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
filename: '[name]/index.js',
},
plugins: [
new LodashModuleReplacementPlugin({
shorthands: true,
collections: true,
paths: true,
}),
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css',
}),
new HtmlWebpackPlugin({
filename: 'popup/index.html',
template: 'src/popup/popup.pug',
chunks: ['popup'],
}),
new HtmlWebpackPlugin({
filename: 'dashboard/index.html',
template: 'src/dashboard/dashboard.pug',
chunks: ['dashboard'],
}),
new webpack.EnvironmentPlugin({
NODE_ENV: mode, // use 'development' unless process.env.NODE_ENV is defined
}),
new CleanUpStatsPlugin('mini-css-extract-plugin'),
new CleanUpStatsPlugin('html-webpack-plugin'),
// TODO: Detect if webpack is run with --watch, not if the PRODUCTION env variable is set
].concat(
mode === DEVELOPMENT
? [
/* new BundleAnalyzerPlugin() */
]
: []
),
},
transpileDependencies: ['vuetify'],
};