@@ -7,10 +7,12 @@ const WebpackBar = require('webpackbar')
7
7
8
8
const config = require ( './config' )
9
9
const HtmlFilterPlugin = require ( './HtmlFilterPlugin' )
10
+ const ServerMiniCssExtractPlugin = require ( './ServerMiniCssExtractPlugin' )
10
11
11
12
exports . getWebpackConfig = ( { target } ) => {
12
13
const service = config . service
13
14
const isProd = service . mode === 'production'
15
+ const isClient = target === 'client'
14
16
15
17
let webpackConfig = service . resolveChainableWebpackConfig ( )
16
18
@@ -21,6 +23,25 @@ exports.getWebpackConfig = ({ target }) => {
21
23
webpackConfig . plugins . delete ( 'progress' )
22
24
webpackConfig . plugins . delete ( 'no-emit-on-errors' )
23
25
26
+ if ( ! isClient ) {
27
+ webpackConfig . plugins . delete ( 'friendly-errors' )
28
+
29
+ // Fix mini-css-extract-plugin error on server
30
+ const langs = [ 'css' , 'postcss' , 'scss' , 'sass' , 'less' , 'stylus' ]
31
+ const types = [ 'vue-modules' , 'vue' , 'normal-modules' , 'normal' ]
32
+ for ( const lang of langs ) {
33
+ for ( const type of types ) {
34
+ const rule = webpackConfig . module . rule ( lang ) . oneOf ( type )
35
+ if ( rule . uses . has ( 'extract-css-loader' ) ) {
36
+ rule . use ( 'extract-css-loader' ) . loader ( ServerMiniCssExtractPlugin . loader )
37
+ }
38
+ }
39
+ }
40
+ if ( webpackConfig . plugins . has ( 'extract-css' ) ) {
41
+ webpackConfig . plugin ( 'extract-css' ) . use ( ServerMiniCssExtractPlugin )
42
+ }
43
+ }
44
+
24
45
// HTML
25
46
webpackConfig . plugin ( 'html-filter' ) . use ( HtmlFilterPlugin )
26
47
if ( isProd ) {
@@ -49,7 +70,6 @@ exports.getWebpackConfig = ({ target }) => {
49
70
} ,
50
71
} )
51
72
52
- const isClient = target === 'client'
53
73
if ( isClient ) {
54
74
webpackConfig = mergeWebpack ( webpackConfig , {
55
75
plugins : [
@@ -80,6 +100,7 @@ exports.getWebpackConfig = ({ target }) => {
80
100
devtool : 'source-map' ,
81
101
optimization : {
82
102
splitChunks : false ,
103
+ minimize : false ,
83
104
} ,
84
105
} )
85
106
0 commit comments