3
3
const path = require ( 'path' ) ;
4
4
const glob = require ( 'glob' ) ;
5
5
const webpack = require ( 'webpack' ) ;
6
- const CleanWebpackPlugin = require ( 'clean-webpack-plugin' ) ;
6
+ const { CleanWebpackPlugin } = require ( 'clean-webpack-plugin' ) ;
7
7
const CopyWebpackPlugin = require ( 'copy-webpack-plugin' ) ;
8
8
const TerserPlugin = require ( 'terser-webpack-plugin' ) ;
9
9
@@ -43,31 +43,24 @@ if (ENV === 'development') {
43
43
optimization : { } ,
44
44
45
45
devServer : ! isTest ? {
46
- historyApiFallback : {
47
- rewrites : [
48
- { from : / \/ * \/ * \. h t m l $ / , to : ( context ) => '/demo' + context . parsedUrl . pathname } ,
49
- { from : / \/ * \/ * \. c s s $ / , to : ( context ) => '/demo' + context . parsedUrl . pathname } ,
50
- { from : / \/ * \/ * \. j s $ / , to : ( context ) => '/demo' + context . parsedUrl . pathname } ,
51
- { from : / \/ u i - s c r o l l - d e m o \. g i f $ / , to : '/demo/ui-scroll-demo.gif' } ,
52
- { from : / ^ \/ $ / , to : '/demo/index.html' }
53
- ]
54
- } ,
55
46
proxy : {
56
47
'/dist' : {
57
48
target : 'http://' + devServerHost + ':' + devServerPort ,
58
49
pathRewrite : { '^/dist' : '' }
59
50
}
60
51
} ,
61
- inline : true ,
62
- quiet : false ,
63
- stats : {
64
- modules : false ,
65
- errors : true ,
66
- warnings : true
67
- } ,
52
+
68
53
port : devServerPort ,
69
54
host : devServerHost ,
70
- publicPath : '/'
55
+ static : "demo" ,
56
+ devMiddleware : {
57
+ stats : {
58
+ modules : false ,
59
+ errors : true ,
60
+ warnings : true
61
+ } ,
62
+ publicPath : '/'
63
+ } ,
71
64
} : { } ,
72
65
73
66
watch : true
@@ -82,7 +75,7 @@ if (ENV === 'production') {
82
75
} ,
83
76
84
77
output : {
85
- path : path . join ( __dirname , 'dist' ) ,
78
+ path : path . resolve ( __dirname , 'dist' ) ,
86
79
filename : '[name].js'
87
80
} ,
88
81
@@ -110,8 +103,8 @@ if (ENV === 'production') {
110
103
} ,
111
104
112
105
plugins : [
113
- new CleanWebpackPlugin ( 'dist' , {
114
- root : __dirname
106
+ new CleanWebpackPlugin ( {
107
+ cleanOnceBeforeBuildPatterns : [ path . join ( __dirname , 'dist/**/*' ) ]
115
108
} ) ,
116
109
new CopyWebpackPlugin ( {
117
110
patterns : [
0 commit comments