mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
feat: modulesDir supports array form
This commit is contained in:
parent
16c12d1e85
commit
f27ddea7d5
@ -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
|
||||
]
|
||||
},
|
||||
|
@ -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')
|
||||
]
|
||||
|
@ -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
|
||||
|
3
test/fixtures/basic/nuxt.config.js
vendored
3
test/fixtures/basic/nuxt.config.js
vendored
@ -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
|
||||
|
4
test/fixtures/with-config/nuxt.config.js
vendored
4
test/fixtures/with-config/nuxt.config.js
vendored
@ -16,7 +16,9 @@ module.exports = {
|
||||
]
|
||||
}
|
||||
},
|
||||
modulesDir: path.join(__dirname, '..', '..', '..', 'node_modules'),
|
||||
modulesDir: [
|
||||
path.join(__dirname, '..', '..', '..', 'node_modules')
|
||||
],
|
||||
transition: 'test',
|
||||
layoutTransition: 'test',
|
||||
loadingIndicator: 'circle',
|
||||
|
Loading…
Reference in New Issue
Block a user