mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
refactor: simplify internal compilers
This commit is contained in:
parent
fe69b71631
commit
f626acf1f9
@ -30,7 +30,7 @@ export default class Builder {
|
|||||||
this.options = nuxt.options
|
this.options = nuxt.options
|
||||||
|
|
||||||
// Fields that set on build
|
// Fields that set on build
|
||||||
this.compiler = null
|
this.compilers = []
|
||||||
this.webpackDevMiddleware = null
|
this.webpackDevMiddleware = null
|
||||||
this.webpackHotMiddleware = null
|
this.webpackHotMiddleware = null
|
||||||
|
|
||||||
@ -408,23 +408,19 @@ export default class Builder {
|
|||||||
compilersOptions.push(dllWebpackConfig.call(this, clientConfig))
|
compilersOptions.push(dllWebpackConfig.call(this, clientConfig))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simulate webpack multi compiler interface
|
|
||||||
// Separate compilers are simpler, safer and faster
|
|
||||||
this.compilers = []
|
|
||||||
|
|
||||||
// Initialize shared FS and Cache
|
// Initialize shared FS and Cache
|
||||||
const sharedFS = this.options.dev && new MFS()
|
const sharedFS = this.options.dev && new MFS()
|
||||||
const sharedCache = {}
|
const sharedCache = {}
|
||||||
|
|
||||||
// Initialize compilers
|
// Initialize compilers
|
||||||
compilersOptions.forEach(compilersOption => {
|
this.compilers = compilersOptions.map(compilersOption => {
|
||||||
const compiler = webpack(compilersOption)
|
const compiler = webpack(compilersOption)
|
||||||
// In dev, write files in memory FS (except for DLL)
|
// In dev, write files in memory FS (except for DLL)
|
||||||
if (sharedFS && !compiler.name.includes('-dll')) {
|
if (sharedFS && !compiler.name.includes('-dll')) {
|
||||||
compiler.outputFileSystem = sharedFS
|
compiler.outputFileSystem = sharedFS
|
||||||
}
|
}
|
||||||
compiler.cache = sharedCache
|
compiler.cache = sharedCache
|
||||||
this.compilers.push(compiler)
|
return compiler
|
||||||
})
|
})
|
||||||
|
|
||||||
// Start Builds
|
// Start Builds
|
||||||
|
Loading…
Reference in New Issue
Block a user