Skip to content

Commit

Permalink
fix(windows): add file protocol to load user configuration on windows
Browse files Browse the repository at this point in the history
release-npm
  • Loading branch information
tobua committed May 5, 2022
1 parent e6db284 commit 70fdf8b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions utility/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ export const loadWebpackConfig = async (development) => {
let userConfiguration = {}
let afterMergeConfiguration
const userConfigurationPath = join(getProjectBasePath(), 'webpack.config.js')
const windowsFileProtocol = process.platform === "win32" ? 'file://' : ''

try {
// Works with module.exports = {} and export default {}.
// The latter only if type in project is set to ES Modules.
userConfiguration = await import(userConfigurationPath)
userConfiguration = await import(`${windowsFileProtocol}${userConfigurationPath}`)

if (userConfiguration.after && typeof userConfiguration.after === 'function') {
afterMergeConfiguration = userConfiguration.after
Expand Down Expand Up @@ -124,11 +125,12 @@ export const loadWebpackConfig = async (development) => {
export const loadSnowpackConfig = async () => {
let configuration = await snowpackConfig()
let userConfiguration = {}
const windowsFileProtocol = process.platform === "win32" ? 'file://' : ''

try {
// Works with module.exports = {} and export default {}.
// The latter only if type in project is set to ES Modules.
userConfiguration = await import(join(getProjectBasePath(), './snowpack.config.js'))
userConfiguration = await import(`${windowsFileProtocol}${join(getProjectBasePath(), './snowpack.config.js')}`)

if (userConfiguration.default) {
userConfiguration = userConfiguration.default
Expand Down

0 comments on commit 70fdf8b

Please sign in to comment.