Skip to content

Commit

Permalink
Use path.posix.join to fix url join issue on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowwalker committed May 12, 2020
1 parent 502ed0c commit fc16e39
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ module.exports = (nextConfig = {}) => ({

config.plugins.push(
new webpack.DefinePlugin({
__PWA_SW__: `"${path.join(subdomainPrefix, _sw)}"`,
__PWA_SCOPE__: `"${path.join(subdomainPrefix, scope)}"`,
__PWA_SW__: `"${path.posix.join(subdomainPrefix, _sw)}"`,
__PWA_SCOPE__: `"${path.posix.join(subdomainPrefix, scope)}"`,
__PWA_ENABLE_REGISTER__: `${Boolean(register)}`
})
)
Expand Down Expand Up @@ -89,8 +89,8 @@ module.exports = (nextConfig = {}) => ({
const _dest = path.join(options.dir, dest)

console.log(`> [PWA] Service worker: ${path.join(_dest, sw)}`)
console.log(`> [PWA] url: ${path.join(subdomainPrefix, _sw)}`)
console.log(`> [PWA] scope: ${path.join(subdomainPrefix, scope)}`)
console.log(`> [PWA] url: ${path.posix.join(subdomainPrefix, _sw)}`)
console.log(`> [PWA] scope: ${path.posix.join(subdomainPrefix, scope)}`)

// build custom worker
let customWorkerEntry = path.join(options.dir, 'worker', 'index.js')
Expand Down Expand Up @@ -143,10 +143,10 @@ module.exports = (nextConfig = {}) => ({
cwd: 'public'
})
.map(f => ({
url: path.join(subdomainPrefix,`/${f}`),
url: path.posix.join(subdomainPrefix,`/${f}`),
revision: getRevision(`public/${f}`)
}))
manifestEntries.push({ url: path.join(subdomainPrefix, '/'), revision: buildId })
manifestEntries.push({ url: path.posix.join(subdomainPrefix, '/'), revision: buildId })
}

const prefix = config.output.publicPath ? `${config.output.publicPath}static/` : 'static/'
Expand All @@ -165,7 +165,7 @@ module.exports = (nextConfig = {}) => ({
}
],
modifyURLPrefix: {
[prefix]: path.join(subdomainPrefix, '/_next/static/')
[prefix]: path.posix.join(subdomainPrefix, '/_next/static/')
}
}

Expand Down

0 comments on commit fc16e39

Please sign in to comment.