Skip to content

Commit

Permalink
chore: 优化构建脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden committed Nov 4, 2021
1 parent 669aa60 commit 1fae0e1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
2 changes: 0 additions & 2 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ const shell = require('shelljs')
const webpack = require('webpack')
const config = require('../webpack.config')

delete config.chromeExtensionBoilerplate

config.mode = 'production'

shell.rm('-rf', 'build')
Expand Down
10 changes: 2 additions & 8 deletions scripts/webserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,17 @@ const config = require('../webpack.config')
const path = require('path')

const PORT = process.env.PORT || 3000
const options = config.chromeExtensionBoilerplate || {}
const excludeEntriesToHotReload = options.notHotReload || []

for (const entryName in config.entry) {
if (excludeEntriesToHotReload.indexOf(entryName) === -1) {
if (['popup', 'background'].indexOf(entryName) > -1) {
config.entry[entryName] = [
'webpack/hot/dev-server',
`webpack-dev-server/client?hot=true&hostname=localhost&port=${PORT}`
].concat(config.entry[entryName])
}
}

config.plugins = [new webpack.HotModuleReplacementPlugin()].concat(
config.plugins || []
)

delete config.chromeExtensionBoilerplate
config.plugins = [new webpack.HotModuleReplacementPlugin(), ...(config.plugins || [])]

const compiler = webpack(config)

Expand Down
8 changes: 1 addition & 7 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ const options = {
clean: true,
publicPath: ASSET_PATH
},
chromeExtensionBoilerplate: {
notHotReload: ['contentScript', 'devtools']
},
module: {
rules: [
{
Expand Down Expand Up @@ -120,10 +117,7 @@ const options = {
chunks: ['background'],
cache: false
})
],
infrastructureLogging: {
level: 'info'
}
]
}

if (process.env.NODE_ENV === 'development') {
Expand Down

0 comments on commit 1fae0e1

Please sign in to comment.