feat: modulesDir option

fixes problems with npx and linked libraries #1076
This commit is contained in:
Pooya Parsa 2017-08-01 02:54:10 +04:30
parent 6d5c248f31
commit 92b6936811
3 changed files with 8 additions and 5 deletions

View File

@ -55,13 +55,13 @@ export default function webpackBaseConfig ({ isClient, isServer }) {
'assets': join(this.options.srcDir, 'assets') // use in template with <img src="~assets/nuxt.png" />
},
modules: [
join(this.options.rootDir, 'node_modules'),
this.options.modulesDir,
nodeModulesDir
]
},
resolveLoader: {
modules: [
join(this.options.rootDir, 'node_modules'),
this.options.modulesDir,
nodeModulesDir
]
},

View File

@ -39,7 +39,8 @@ export default function webpackServerConfig () {
// https://github.com/liady/webpack-node-externals
nodeExternals({
// load non-javascript files with extensions, presumably via loaders
whitelist: [/\.(?!(?:js|json)$).{1,5}$/i]
whitelist: [/\.(?!(?:js|json)$).{1,5}$/i],
modulesDir: this.options.modulesDir
})
],
plugins: (config.plugins || []).concat([

View File

@ -25,8 +25,10 @@ export default function Options (_options) {
_.defaultsDeep(options, Options.defaults)
// Resolve dirs
options.rootDir = (typeof options.rootDir === 'string' && options.rootDir ? options.rootDir : process.cwd())
options.srcDir = (typeof options.srcDir === 'string' && options.srcDir ? resolve(options.rootDir, options.srcDir) : options.rootDir)
const hasValue = v => typeof v === 'string' && v
options.rootDir = hasValue(options.rootDir) ? options.rootDir : process.cwd()
options.srcDir = hasValue(options.srcDir) ? resolve(options.rootDir, options.srcDir) : options.rootDir
options.modulesDir = resolve(options.rootDir, hasValue(options.modulesDir) ? options.modulesDir : 'node_modules')
options.buildDir = join(options.rootDir, options.buildDir)
// If app.html is defined, set the template path to the user template