Skip to content

Commit 64e3234

Browse files
committed
Fixing production builds and manifest asset matching.
- Disabling most of the hash inclusions in file names in favor of hashed URL params
1 parent d8c1450 commit 64e3234

File tree

5 files changed

+1818
-36
lines changed

5 files changed

+1818
-36
lines changed

generator/template/src/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"homepage_url": "http://localhost/",
1010
"description": "A Vue Browser Extension",
1111
"version": "1.0",
12-
"permissions": ["activeTab", "http://*/*", "https://*/*"],
12+
"permissions": ["<all_urls>", "*://*/*"],
1313
"background": {
1414
"scripts": ["background.js"],
1515
"persistent": false

generator/template/src/popup/popup.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8">
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7-
<title><%- rootOptions.projectName %></title>
7+
<title><%= htmlWebpackPlugin.options.title %></title>
88
<link rel="stylesheet" href="popup.css">
99
</head>
1010
<body>

index.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@ const { log } = require('@vue/cli-shared-utils')
33
const CopyWebpackPlugin = require('copy-webpack-plugin')
44
const ChromeExtensionReloader = require('webpack-chrome-extension-reloader')
55
const WebpackShellPlugin = require('webpack-shell-plugin-next')
6-
const { version } = require('./package.json')
6+
const HtmlWebpackPlugin = require('html-webpack-plugin')
7+
const { name, version } = require('./package.json')
78

89
module.exports = (api) => {
910
api.configureWebpack(webpackConfig => {
11+
webpackConfig.output.filename = '[name].js'
12+
webpackConfig.output.chunkFilename = 'js/[id].[name].js?[hash:8]'
13+
1014
delete webpackConfig.entry.app
1115
webpackConfig.entry.background = './src/background.js'
1216
webpackConfig.entry['popup/popup'] = './src/popup/popup.js'
1317

1418
webpackConfig.plugins.push(new CopyWebpackPlugin([
15-
{ from: './src/icons', to: 'icons', ignore: ['icon.xcf'] },
16-
{ from: './src/popup/popup.html', to: 'popup/popup.html' },
19+
{ from: './src/icons', to: 'icons/[name].[ext]', ignore: ['icon.xcf'] },
1720
{
1821
from: './src/manifest.json',
1922
to: 'manifest.json',
@@ -30,6 +33,17 @@ module.exports = (api) => {
3033
}
3134
]))
3235

36+
webpackConfig.plugins.push(new HtmlWebpackPlugin({
37+
title: name,
38+
hash: true,
39+
cache: true,
40+
inject: 'body',
41+
filename: './popup/popup.html',
42+
template: './src/popup/popup.html',
43+
appMountId: 'app',
44+
chunks: ['popup/popup', 'chunk-vendors']
45+
}))
46+
3347
const scriptPath = path.join(__dirname, 'scripts/remove-evals.js')
3448
webpackConfig.plugins.push(new WebpackShellPlugin({
3549
onBuildExit: {
@@ -39,9 +53,13 @@ module.exports = (api) => {
3953
}
4054
}))
4155

42-
if (process.env.HMR === 'true') {
56+
if (process.env.NODE_ENV === 'development') {
4357
webpackConfig.plugins = (webpackConfig.plugins || []).concat([
44-
new ChromeExtensionReloader()
58+
new ChromeExtensionReloader({
59+
entries: {
60+
background: 'background'
61+
}
62+
})
4563
])
4664
}
4765
})

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-cli-plugin-browser-extension",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"description": "Browser extension development plugin for vue-cli 3.0",
55
"main": "index.js",
66
"scripts": {
@@ -26,6 +26,8 @@
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",
30+
"webpack": "^4.16.0",
2931
"webpack-chrome-extension-reloader": "^0.8.3",
3032
"webpack-shell-plugin-next": "https://github.com/adambullmer/webpack-shell-plugin-next.git"
3133
}

0 commit comments

Comments
 (0)