33const path = require ( 'path' ) ;
44const glob = require ( 'glob' ) ;
55const webpack = require ( 'webpack' ) ;
6- const CleanWebpackPlugin = require ( 'clean-webpack-plugin' ) ;
6+ const { CleanWebpackPlugin } = require ( 'clean-webpack-plugin' ) ;
77const CopyWebpackPlugin = require ( 'copy-webpack-plugin' ) ;
88const TerserPlugin = require ( 'terser-webpack-plugin' ) ;
99
@@ -43,31 +43,24 @@ if (ENV === 'development') {
4343 optimization : { } ,
4444
4545 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- } ,
5546 proxy : {
5647 '/dist' : {
5748 target : 'http://' + devServerHost + ':' + devServerPort ,
5849 pathRewrite : { '^/dist' : '' }
5950 }
6051 } ,
61- inline : true ,
62- quiet : false ,
63- stats : {
64- modules : false ,
65- errors : true ,
66- warnings : true
67- } ,
52+
6853 port : devServerPort ,
6954 host : devServerHost ,
70- publicPath : '/'
55+ static : "demo" ,
56+ devMiddleware : {
57+ stats : {
58+ modules : false ,
59+ errors : true ,
60+ warnings : true
61+ } ,
62+ publicPath : '/'
63+ } ,
7164 } : { } ,
7265
7366 watch : true
@@ -82,7 +75,7 @@ if (ENV === 'production') {
8275 } ,
8376
8477 output : {
85- path : path . join ( __dirname , 'dist' ) ,
78+ path : path . resolve ( __dirname , 'dist' ) ,
8679 filename : '[name].js'
8780 } ,
8881
@@ -110,8 +103,8 @@ if (ENV === 'production') {
110103 } ,
111104
112105 plugins : [
113- new CleanWebpackPlugin ( 'dist' , {
114- root : __dirname
106+ new CleanWebpackPlugin ( {
107+ cleanOnceBeforeBuildPatterns : [ path . join ( __dirname , 'dist/**/*' ) ]
115108 } ) ,
116109 new CopyWebpackPlugin ( {
117110 patterns : [
0 commit comments