Skip to content

Commit

Permalink
fix($core): globally installed vuepress doesn't work (close: #908, #949)
Browse files Browse the repository at this point in the history
  • Loading branch information
ulivz committed Oct 27, 2018
1 parent 636bd81 commit af80c4b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/@vuepress/core/lib/webpack/createBaseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ module.exports = function createBaseConfig ({
config.devtool('cheap-module-eval-source-map')
}

const modulePaths = getModulePaths()
logger.debug('modulePaths = ' + JSON.stringify(modulePaths, null, 2))

config.resolve
.set('symlinks', true)
.alias
Expand All @@ -60,18 +63,12 @@ module.exports = function createBaseConfig ({
.merge(['.js', '.jsx', '.vue', '.json', '.styl'])
.end()
.modules
// prioritize our own
.add(path.resolve(__dirname, '../../node_modules'))
.add(path.resolve(__dirname, '../../../'))
.add('node_modules')
.merge(modulePaths)

config.resolveLoader
.set('symlinks', true)
.modules
// prioritize our own
.add(path.resolve(__dirname, '../../node_modules'))
.add(path.resolve(__dirname, '../../../'))
.add('node_modules')
.merge(modulePaths)

config.module
.noParse(/^(vue|vue-router|vuex|vuex-router-sync)$/)
Expand Down Expand Up @@ -320,3 +317,7 @@ function getLastCommitHash () {
} catch (error) {}
return hash
}

function getModulePaths () {
return [path.resolve(process.cwd(), 'node_modules')].concat(module.paths)
}

0 comments on commit af80c4b

Please sign in to comment.