Skip to content

Commit af80c4b

Browse files
committed
fix($core): globally installed vuepress doesn't work (close: #908, #949)
1 parent 636bd81 commit af80c4b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

packages/@vuepress/core/lib/webpack/createBaseConfig.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ module.exports = function createBaseConfig ({
4646
config.devtool('cheap-module-eval-source-map')
4747
}
4848

49+
const modulePaths = getModulePaths()
50+
logger.debug('modulePaths = ' + JSON.stringify(modulePaths, null, 2))
51+
4952
config.resolve
5053
.set('symlinks', true)
5154
.alias
@@ -60,18 +63,12 @@ module.exports = function createBaseConfig ({
6063
.merge(['.js', '.jsx', '.vue', '.json', '.styl'])
6164
.end()
6265
.modules
63-
// prioritize our own
64-
.add(path.resolve(__dirname, '../../node_modules'))
65-
.add(path.resolve(__dirname, '../../../'))
66-
.add('node_modules')
66+
.merge(modulePaths)
6767

6868
config.resolveLoader
6969
.set('symlinks', true)
7070
.modules
71-
// prioritize our own
72-
.add(path.resolve(__dirname, '../../node_modules'))
73-
.add(path.resolve(__dirname, '../../../'))
74-
.add('node_modules')
71+
.merge(modulePaths)
7572

7673
config.module
7774
.noParse(/^(vue|vue-router|vuex|vuex-router-sync)$/)
@@ -320,3 +317,7 @@ function getLastCommitHash () {
320317
} catch (error) {}
321318
return hash
322319
}
320+
321+
function getModulePaths () {
322+
return [path.resolve(process.cwd(), 'node_modules')].concat(module.paths)
323+
}

0 commit comments

Comments
 (0)