mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27: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')
|
'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
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -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')
|
||||||
]
|
]
|
||||||
|
@ -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
|
||||||
|
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 = {
|
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
|
||||||
|
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',
|
transition: 'test',
|
||||||
layoutTransition: 'test',
|
layoutTransition: 'test',
|
||||||
loadingIndicator: 'circle',
|
loadingIndicator: 'circle',
|
||||||
|
Loading…
Reference in New Issue
Block a user