Skip to content

Commit 94357f4

Browse files
committed
Refactored build pipeline to take advantage of vue's pages config
1 parent 8629666 commit 94357f4

File tree

3 files changed

+17
-32
lines changed

3 files changed

+17
-32
lines changed

generator/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ module.exports = (api, options) => {
1919
'vuex': '^3.0.1'
2020
}
2121
}
22+
const renderConfig = {
23+
pages: {
24+
'popup/popup': {
25+
entry: 'src/popup/popup.js',
26+
title: 'Popup'
27+
}
28+
}
29+
}
2230

2331
if (api.hasPlugin('eslint')) {
2432
console.log('Adding eslint config stuffs')
@@ -30,8 +38,17 @@ module.exports = (api, options) => {
3038

3139
if (options.optionsPage) {
3240
api.render('./template/options', { ...options })
41+
42+
renderConfig.pages['options/options'] = {
43+
entry: 'src/options/options.js',
44+
title: 'Options'
45+
}
3346
}
3447

48+
api.render((files) => {
49+
files['vue.config.js'] = api.genJSConfig(renderConfig)
50+
})
51+
3552
api.onCreateComplete(() => {
3653
const gitignore = fs.readFileSync(api.resolve('./.gitignore'), 'utf8')
3754
fs.writeFileSync(api.resolve('./.gitignore'), gitignore + gitignoreSnippet)

index.js

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const logger = require('@vue/cli-shared-utils')
55
const CopyWebpackPlugin = require('copy-webpack-plugin')
66
const ChromeExtensionReloader = require('webpack-chrome-extension-reloader')
77
const WebpackShellPlugin = require('webpack-shell-plugin-next')
8-
const HtmlWebpackPlugin = require('html-webpack-plugin')
98
const ZipPlugin = require('zip-webpack-plugin')
109

1110
const appRootPath = process.cwd()
@@ -16,7 +15,6 @@ module.exports = (api) => {
1615
const isProduction = api.service.mode === 'production'
1716
const outputDir = api.resolve(api.service.projectOptions.outputDir || 'dist')
1817
const packageScript = isProduction ? null : 'remove-evals.js'
19-
const hasOptionsPageEntry = fs.existsSync(api.resolve('./src/options/options.js'))
2018
const hasKeyFile = fs.existsSync(api.resolve('key.pem'))
2119

2220
api.configureWebpack((webpackConfig) => {
@@ -25,11 +23,6 @@ module.exports = (api) => {
2523

2624
delete webpackConfig.entry.app
2725
webpackConfig.entry.background = './src/background.js'
28-
webpackConfig.entry['popup/popup'] = './src/popup/popup.js'
29-
30-
if (hasOptionsPageEntry) {
31-
webpackConfig.entry['options/options'] = './src/options/options.js'
32-
}
3326

3427
if (isProduction) {
3528
if (hasKeyFile) {
@@ -81,30 +74,6 @@ module.exports = (api) => {
8174
}
8275
]))
8376

84-
webpackConfig.plugins.push(new HtmlWebpackPlugin({
85-
title: name,
86-
hash: true,
87-
cache: true,
88-
inject: 'body',
89-
filename: './popup/popup.html',
90-
template: './src/popup/popup.html',
91-
appMountId: 'app',
92-
chunks: ['popup/popup', 'chunk-vendors']
93-
}))
94-
95-
if (hasOptionsPageEntry) {
96-
webpackConfig.plugins.push(new HtmlWebpackPlugin({
97-
title: name,
98-
hash: true,
99-
cache: true,
100-
inject: 'body',
101-
filename: './options/options.html',
102-
template: './src/options/options.html',
103-
appMountId: 'app',
104-
chunks: ['options/options', 'chunk-vendors']
105-
}))
106-
}
107-
10877
if (packageScript === null) {
10978
webpackConfig.plugins.push(new ZipPlugin({
11079
path: api.resolve(`${api.service.projectOptions.outputDir || 'dist'}-zip`),

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"dependencies": {
2727
"@vue/cli-shared-utils": "^3.0.0-rc.3",
2828
"copy-webpack-plugin": "^4.5.2",
29-
"html-webpack-plugin": "^3.2.0",
3029
"webpack": "^4.16.0",
3130
"webpack-chrome-extension-reloader": "^0.8.3",
3231
"webpack-shell-plugin-next": "https://github.com/adambullmer/webpack-shell-plugin-next.git",

0 commit comments

Comments
 (0)