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')
},
modules: [
this.options.modulesDir,
...this.options.modulesDir,
nodeModulesDir
]
},
resolveLoader: {
modules: [
this.options.modulesDir,
...this.options.modulesDir,
nodeModulesDir
]
},

View File

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

View File

@ -39,10 +39,20 @@ Options.from = function (_options) {
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 = resolve(options.rootDir, options.buildDir)
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
options.appTemplatePath = resolve(options.buildDir, 'views/app.template.html')
if (existsSync(join(options.srcDir, 'app.html'))) {
@ -126,7 +136,7 @@ Options.from = function (_options) {
path: [
options.srcDir,
options.rootDir,
options.modulesDir
...options.modulesDir
]
},
// https://github.com/postcss/postcss-url

View File

@ -1,3 +1,5 @@
const path = require('path')
module.exports = {
generate: {
routes: [
@ -8,6 +10,7 @@ module.exports = {
interval: 200,
subFolders: true
},
modulesDir: path.join(__dirname, '..', '..', '..', 'node_modules'),
hooks: {
ready(nuxt) {
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',
layoutTransition: 'test',
loadingIndicator: 'circle',