Skip to content

Commit 2c1ad14

Browse files
committed
fix: ensure paths + make html optional
1 parent 655202f commit 2c1ad14

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

packages/@vue/cli-service/lib/commands/serve.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ module.exports = (api, options) => {
6060
if (!isProduction) {
6161
const devClients = [
6262
// dev server client
63-
`webpack-dev-server/client/?${urls.localUrlForBrowser}`,
63+
require.resolve(`webpack-dev-server/client`) + `?${urls.localUrlForBrowser}`,
6464
// hmr client
65-
projectDevServerOptions.hotOnly
65+
require.resolve(projectDevServerOptions.hotOnly
6666
? 'webpack/hot/only-dev-server'
67-
: 'webpack/hot/dev-server'
67+
: 'webpack/hot/dev-server')
6868
// TODO custom overlay client
6969
// `@vue/cli-overlay/dist/client`
7070
]

packages/@vue/cli-service/lib/config/base.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = (api, options) => {
22
api.chainWebpack(webpackConfig => {
3+
const fs = require('fs')
34
const resolveLocal = require('../util/resolveLocal')
45
const resolveClientEnv = require('../util/resolveClientEnv')
56

@@ -98,11 +99,12 @@ module.exports = (api, options) => {
9899
child_process: 'empty'
99100
})
100101

102+
const htmlPath = api.resolve('public/index.html')
101103
webpackConfig
102104
.plugin('html')
103-
.use(require('html-webpack-plugin'), [{
104-
template: api.resolve('public/index.html')
105-
}])
105+
.use(require('html-webpack-plugin'), [
106+
fs.existsSync(htmlPath) ? { template: htmlPath } : {}
107+
])
106108

107109
// inject preload/prefetch to HTML
108110
const PreloadPlugin = require('../webpack/PreloadPlugin')

0 commit comments

Comments
 (0)