From bfafcb9c1aff48bc2ed1d591261f1ff2046b76d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Mon, 9 Jan 2017 15:10:22 +0100 Subject: [PATCH] Fix server build with CSS modules --- lib/build/index.js | 2 +- lib/build/webpack/base.config.js | 4 ++-- lib/build/webpack/client.config.js | 2 +- lib/build/webpack/server.config.js | 2 +- lib/build/webpack/vue-loader.config.js | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/build/index.js b/lib/build/index.js index 2007ee69d2..cafb08514d 100644 --- a/lib/build/index.js +++ b/lib/build/index.js @@ -55,7 +55,7 @@ const defaultsLoaders = [ loader: 'url-loader', query: { limit: 1000, // 1KO - name: 'img/[name].[ext]?[hash]' + name: 'img/[name].[hash:7].[ext]' } }, { diff --git a/lib/build/webpack/base.config.js b/lib/build/webpack/base.config.js index a2d9f64ac3..a48edcb02c 100644 --- a/lib/build/webpack/base.config.js +++ b/lib/build/webpack/base.config.js @@ -13,7 +13,7 @@ const { urlJoin } = require('../../utils') | webpack config files |-------------------------------------------------------------------------- */ -module.exports = function () { +module.exports = function ({ isClient, isServer }) { const nodeModulesDir = join(__dirname, '..', 'node_modules') let config = { devtool: 'source-map', @@ -57,7 +57,7 @@ module.exports = function () { { test: /\.vue$/, loader: 'vue-loader', - query: vueLoaderConfig.call(this) + query: vueLoaderConfig.call(this, { isClient, isServer }) }, { test: /\.js$/, diff --git a/lib/build/webpack/client.config.js b/lib/build/webpack/client.config.js index 0a8e1a1975..103a5d193e 100644 --- a/lib/build/webpack/client.config.js +++ b/lib/build/webpack/client.config.js @@ -17,7 +17,7 @@ const { resolve } = require('path') |-------------------------------------------------------------------------- */ module.exports = function () { - let config = base.call(this) + let config = base.call(this, { isClient: true }) // Entry config.entry.app = resolve(this.dir, '.nuxt', 'client.js') diff --git a/lib/build/webpack/server.config.js b/lib/build/webpack/server.config.js index 09dbc80708..db12778d9e 100644 --- a/lib/build/webpack/server.config.js +++ b/lib/build/webpack/server.config.js @@ -13,7 +13,7 @@ const { resolve } = require('path') |-------------------------------------------------------------------------- */ module.exports = function () { - let config = base.call(this) + let config = base.call(this, { isServer: true }) // env object defined in nuxt.config.js let env = {} diff --git a/lib/build/webpack/vue-loader.config.js b/lib/build/webpack/vue-loader.config.js index 6cb550f9c6..2d4b36dd3e 100644 --- a/lib/build/webpack/vue-loader.config.js +++ b/lib/build/webpack/vue-loader.config.js @@ -2,7 +2,7 @@ const { defaults } = require('lodash') -module.exports = function () { +module.exports = function ({ isClient }) { let babelOptions = JSON.stringify(defaults(this.options.build.babel, { plugins: [ 'transform-async-to-generator', @@ -26,7 +26,7 @@ module.exports = function () { preserveWhitespace: false } - if (!this.dev) { + if (!this.dev && isClient) { // Use ExtractTextPlugin to extract CSS into a single file const ExtractTextPlugin = require('extract-text-webpack-plugin') config.loaders.css = ExtractTextPlugin.extract({ loader: 'css-loader' })