mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-01 17:53:38 +00:00
Fix server build with CSS modules
This commit is contained in:
parent
f8de9dbe0d
commit
bfafcb9c1a
@ -55,7 +55,7 @@ const defaultsLoaders = [
|
|||||||
loader: 'url-loader',
|
loader: 'url-loader',
|
||||||
query: {
|
query: {
|
||||||
limit: 1000, // 1KO
|
limit: 1000, // 1KO
|
||||||
name: 'img/[name].[ext]?[hash]'
|
name: 'img/[name].[hash:7].[ext]'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ const { urlJoin } = require('../../utils')
|
|||||||
| webpack config files
|
| webpack config files
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
module.exports = function () {
|
module.exports = function ({ isClient, isServer }) {
|
||||||
const nodeModulesDir = join(__dirname, '..', 'node_modules')
|
const nodeModulesDir = join(__dirname, '..', 'node_modules')
|
||||||
let config = {
|
let config = {
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
@ -57,7 +57,7 @@ module.exports = function () {
|
|||||||
{
|
{
|
||||||
test: /\.vue$/,
|
test: /\.vue$/,
|
||||||
loader: 'vue-loader',
|
loader: 'vue-loader',
|
||||||
query: vueLoaderConfig.call(this)
|
query: vueLoaderConfig.call(this, { isClient, isServer })
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
|
@ -17,7 +17,7 @@ const { resolve } = require('path')
|
|||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
module.exports = function () {
|
module.exports = function () {
|
||||||
let config = base.call(this)
|
let config = base.call(this, { isClient: true })
|
||||||
|
|
||||||
// Entry
|
// Entry
|
||||||
config.entry.app = resolve(this.dir, '.nuxt', 'client.js')
|
config.entry.app = resolve(this.dir, '.nuxt', 'client.js')
|
||||||
|
@ -13,7 +13,7 @@ const { resolve } = require('path')
|
|||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
module.exports = function () {
|
module.exports = function () {
|
||||||
let config = base.call(this)
|
let config = base.call(this, { isServer: true })
|
||||||
|
|
||||||
// env object defined in nuxt.config.js
|
// env object defined in nuxt.config.js
|
||||||
let env = {}
|
let env = {}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
const { defaults } = require('lodash')
|
const { defaults } = require('lodash')
|
||||||
|
|
||||||
module.exports = function () {
|
module.exports = function ({ isClient }) {
|
||||||
let babelOptions = JSON.stringify(defaults(this.options.build.babel, {
|
let babelOptions = JSON.stringify(defaults(this.options.build.babel, {
|
||||||
plugins: [
|
plugins: [
|
||||||
'transform-async-to-generator',
|
'transform-async-to-generator',
|
||||||
@ -26,7 +26,7 @@ module.exports = function () {
|
|||||||
preserveWhitespace: false
|
preserveWhitespace: false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.dev) {
|
if (!this.dev && isClient) {
|
||||||
// Use ExtractTextPlugin to extract CSS into a single file
|
// Use ExtractTextPlugin to extract CSS into a single file
|
||||||
const ExtractTextPlugin = require('extract-text-webpack-plugin')
|
const ExtractTextPlugin = require('extract-text-webpack-plugin')
|
||||||
config.loaders.css = ExtractTextPlugin.extract({ loader: 'css-loader' })
|
config.loaders.css = ExtractTextPlugin.extract({ loader: 'css-loader' })
|
||||||
|
Loading…
Reference in New Issue
Block a user