From f626acf1f95a5cd4d97c300e011f7c646aaff105 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 7 Nov 2017 13:16:29 +0330 Subject: [PATCH] refactor: simplify internal compilers --- lib/builder/builder.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/builder/builder.js b/lib/builder/builder.js index 91f3a66746..fd970b902f 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -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