feat: modulesDir supports array form

This commit is contained in:
Clark Du 2017-11-24 17:16:17 +08:00
parent 16c12d1e85
commit f27ddea7d5
5 changed files with 21 additions and 6 deletions

View File

@ -48,13 +48,13 @@ export default function webpackBaseConfig(name) {
'static': join(this.options.srcDir, 'static') 'static': join(this.options.srcDir, 'static')
}, },
modules: [ modules: [
this.options.modulesDir, ...this.options.modulesDir,
nodeModulesDir nodeModulesDir
] ]
}, },
resolveLoader: { resolveLoader: {
modules: [ modules: [
this.options.modulesDir, ...this.options.modulesDir,
nodeModulesDir nodeModulesDir
] ]
}, },

View File

@ -53,7 +53,7 @@ export default function webpackServerConfig() {
// https://webpack.js.org/configuration/externals/#externals // https://webpack.js.org/configuration/externals/#externals
// https://github.com/liady/webpack-node-externals // https://github.com/liady/webpack-node-externals
const moduleDirs = [ const moduleDirs = [
this.options.modulesDir ...this.options.modulesDir
// Temporary disabled due to vue-server-renderer module search limitations // Temporary disabled due to vue-server-renderer module search limitations
// resolve(__dirname, '..', 'node_modules') // resolve(__dirname, '..', 'node_modules')
] ]

View File

@ -39,10 +39,20 @@ Options.from = function (_options) {
const hasValue = v => typeof v === 'string' && v const hasValue = v => typeof v === 'string' && v
options.rootDir = hasValue(options.rootDir) ? options.rootDir : process.cwd() options.rootDir = hasValue(options.rootDir) ? options.rootDir : process.cwd()
options.srcDir = hasValue(options.srcDir) ? resolve(options.rootDir, options.srcDir) : options.rootDir 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 = resolve(options.rootDir, options.buildDir) options.buildDir = resolve(options.rootDir, options.buildDir)
options.cacheDir = resolve(options.rootDir, options.cacheDir) options.cacheDir = resolve(options.rootDir, options.cacheDir)
if (Array.isArray(options.modulesDir) && options.modulesDir.length) {
options.modulesDir = options.modulesDir.reduce((modules, dir) => {
if (hasValue(dir)) {
modules.push(resolve(options.rootDir, dir))
}
return modules
}, [])
} else {
options.modulesDir = [resolve(options.rootDir, hasValue(options.modulesDir) ? options.modulesDir : 'node_modules')]
}
// If app.html is defined, set the template path to the user template // If app.html is defined, set the template path to the user template
options.appTemplatePath = resolve(options.buildDir, 'views/app.template.html') options.appTemplatePath = resolve(options.buildDir, 'views/app.template.html')
if (existsSync(join(options.srcDir, 'app.html'))) { if (existsSync(join(options.srcDir, 'app.html'))) {
@ -126,7 +136,7 @@ Options.from = function (_options) {
path: [ path: [
options.srcDir, options.srcDir,
options.rootDir, options.rootDir,
options.modulesDir ...options.modulesDir
] ]
}, },
// https://github.com/postcss/postcss-url // https://github.com/postcss/postcss-url

View File

@ -1,3 +1,5 @@
const path = require('path')
module.exports = { module.exports = {
generate: { generate: {
routes: [ routes: [
@ -8,6 +10,7 @@ module.exports = {
interval: 200, interval: 200,
subFolders: true subFolders: true
}, },
modulesDir: path.join(__dirname, '..', '..', '..', 'node_modules'),
hooks: { hooks: {
ready(nuxt) { ready(nuxt) {
nuxt.__hook_called__ = true nuxt.__hook_called__ = true

View File

@ -16,7 +16,9 @@ module.exports = {
] ]
} }
}, },
modulesDir: path.join(__dirname, '..', '..', '..', 'node_modules'), modulesDir: [
path.join(__dirname, '..', '..', '..', 'node_modules')
],
transition: 'test', transition: 'test',
layoutTransition: 'test', layoutTransition: 'test',
loadingIndicator: 'circle', loadingIndicator: 'circle',