feat(webpack,cli): standalone build mode (#4661)

* feat(webpack,cli): standalone build mode

* revert typo
This commit is contained in:
Pooya Parsa 2019-01-03 23:57:50 +03:30 committed by GitHub
parent a4c503bfbb
commit bdb6791e40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 10 deletions

View File

@ -46,6 +46,16 @@ export default {
options.build.quiet = !!argv.quiet
}
}
},
standalone: {
type: 'boolean',
default: false,
description: 'Bundle all server dependencies (useful for nuxt-start)',
prepare(cmd, options, argv) {
if (argv.standalone) {
options.build.standalone = true
}
}
}
},
async run(cmd) {

View File

@ -10,6 +10,7 @@ export default () => ({
ssr: undefined,
parallel: false,
cache: false,
standalone: false,
publicPath: '/_nuxt/',
filenames: {
// { isDev, isClient, isServer }

View File

@ -86,16 +86,18 @@ export default class WebpackServerConfig extends WebpackBaseConfig {
// https://webpack.js.org/configuration/externals/#externals
// https://github.com/liady/webpack-node-externals
// https://vue-loader.vuejs.org/migrating.html#ssr-externals
this.options.modulesDir.forEach((dir) => {
if (fs.existsSync(dir)) {
config.externals.push(
nodeExternals({
whitelist: this.whitelist,
modulesDir: dir
})
)
}
})
if (!this.options.build.standalone && !this.options.dev) {
this.options.modulesDir.forEach((dir) => {
if (fs.existsSync(dir)) {
config.externals.push(
nodeExternals({
whitelist: this.whitelist,
modulesDir: dir
})
)
}
})
}
return config
}