refactor: simplify internal compilers

This commit is contained in:
Pooya Parsa 2017-11-07 13:16:29 +03:30
parent fe69b71631
commit f626acf1f9

View File

@ -30,7 +30,7 @@ export default class Builder {
this.options = nuxt.options
// Fields that set on build
this.compiler = null
this.compilers = []
this.webpackDevMiddleware = null
this.webpackHotMiddleware = null
@ -408,23 +408,19 @@ export default class Builder {
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
const sharedFS = this.options.dev && new MFS()
const sharedCache = {}
// Initialize compilers
compilersOptions.forEach(compilersOption => {
this.compilers = compilersOptions.map(compilersOption => {
const compiler = webpack(compilersOption)
// In dev, write files in memory FS (except for DLL)
if (sharedFS && !compiler.name.includes('-dll')) {
compiler.outputFileSystem = sharedFS
}
compiler.cache = sharedCache
this.compilers.push(compiler)
return compiler
})
// Start Builds