Fix server build with CSS modules

This commit is contained in:
Sébastien Chopin 2017-01-09 15:10:22 +01:00
parent f8de9dbe0d
commit bfafcb9c1a
5 changed files with 7 additions and 7 deletions

View File

@ -55,7 +55,7 @@ const defaultsLoaders = [
loader: 'url-loader',
query: {
limit: 1000, // 1KO
name: 'img/[name].[ext]?[hash]'
name: 'img/[name].[hash:7].[ext]'
}
},
{

View File

@ -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$/,

View File

@ -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')

View File

@ -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 = {}

View File

@ -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' })