From 452747b3c47fa87b3cbb3b03000b87f2332f9988 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 5 Jan 2018 03:04:20 +0330 Subject: [PATCH] perf,fix: source map improvements --- lib/builder/webpack/base.config.js | 4 +--- lib/builder/webpack/client.config.js | 4 ++++ lib/builder/webpack/server.config.js | 6 ++++-- lib/common/options.js | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/builder/webpack/base.config.js b/lib/builder/webpack/base.config.js index 346723d721..e6cb1e4d88 100644 --- a/lib/builder/webpack/base.config.js +++ b/lib/builder/webpack/base.config.js @@ -18,7 +18,6 @@ const WarnFixPlugin = require('./plugins/warnfix') module.exports = function webpackBaseConfig({ name, isServer }) { const config = { name, - devtool: this.options.dev ? 'cheap-source-map' : false, entry: { app: null }, @@ -28,8 +27,7 @@ module.exports = function webpackBaseConfig({ name, isServer }) { chunkFilename: this.getFileName('chunk'), publicPath: (isUrl(this.options.build.publicPath) ? this.options.build.publicPath - : urlJoin(this.options.router.base, this.options.build.publicPath)), - devtoolModuleFilenameTemplate: '[absolute-resource-path]' + : urlJoin(this.options.router.base, this.options.build.publicPath)) }, performance: { maxEntrypointSize: 1000000, diff --git a/lib/builder/webpack/client.config.js b/lib/builder/webpack/client.config.js index 6d975b73c4..b49890e53d 100644 --- a/lib/builder/webpack/client.config.js +++ b/lib/builder/webpack/client.config.js @@ -33,6 +33,10 @@ module.exports = function webpackClientConfig() { config.entry.app = resolve(this.options.buildDir, 'client.js') config.entry.vendor = this.vendor() + // Config devtool + config.devtool = this.options.dev ? 'cheap-source-map' : false + config.output.devtoolModuleFilenameTemplate = '[absolute-resource-path]' + // Add CommonChunks plugin commonChunksPlugin.call(this, config) diff --git a/lib/builder/webpack/server.config.js b/lib/builder/webpack/server.config.js index c3ecde4276..56a5ebc099 100644 --- a/lib/builder/webpack/server.config.js +++ b/lib/builder/webpack/server.config.js @@ -14,16 +14,18 @@ const base = require('./base.config.js') module.exports = function webpackServerConfig() { let config = base.call(this, { name: 'server', isServer: true }) - // env object defined in nuxt.config.js + // Env object defined in nuxt.config.js let env = {} each(this.options.env, (value, key) => { env['process.env.' + key] = (['boolean', 'number'].indexOf(typeof value) !== -1 ? value : JSON.stringify(value)) }) + // Config devtool + config.devtool = this.options.dev ? 'cheap-source-map' : false + config = Object.assign(config, { target: 'node', node: false, - devtool: 'source-map', entry: resolve(this.options.buildDir, 'server.js'), output: Object.assign({}, config.output, { filename: 'server-bundle.js', diff --git a/lib/common/options.js b/lib/common/options.js index b43b75ff57..4db8c8b044 100755 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -163,7 +163,7 @@ Options.defaults = { uglify: {}, publicPath: '/_nuxt/', filenames: { - css: 'css/[name].[contenthash].css', + css: '[name].[contenthash].css', manifest: 'manifest.[hash].js', vendor: 'vendor.[chunkhash].js', app: 'app.[chunkhash].js',