1- var path = require ( 'path' )
2- var webpack = require ( 'webpack' )
1+ const path = require ( 'path' )
2+ const webpack = require ( 'webpack' )
3+ const { VueLoaderPlugin } = require ( 'vue-loader' )
34
45module . exports = {
6+ mode : process . env . NODE_ENV || 'development' ,
57 entry : './src/main.js' ,
68 output : {
79 path : path . resolve ( __dirname , './dist' ) ,
810 publicPath : '/dist/' ,
9- filename : 'build.js'
11+ filename : 'build.js' ,
12+ clean : true
1013 } ,
1114 module : {
1215 rules : [
@@ -16,14 +19,10 @@ module.exports = {
1619 'vue-style-loader' ,
1720 'css-loader'
1821 ] ,
19- } , {
22+ } ,
23+ {
2024 test : / \. v u e $ / ,
21- loader : 'vue-loader' ,
22- options : {
23- loaders : {
24- }
25- // other vue-loader options go here
26- }
25+ loader : 'vue-loader'
2726 } ,
2827 {
2928 test : / \. j s $ / ,
@@ -32,47 +31,36 @@ module.exports = {
3231 } ,
3332 {
3433 test : / \. ( p n g | j p g | g i f | s v g ) $ / ,
35- loader : 'file-loader ' ,
36- options : {
37- name : '[name].[ext]?[hash ]'
34+ type : 'asset/resource ' ,
35+ generator : {
36+ filename : '[name].[hash][ext ]'
3837 }
3938 }
4039 ]
4140 } ,
41+ plugins : [
42+ new VueLoaderPlugin ( ) ,
43+ new webpack . DefinePlugin ( {
44+ __VUE_OPTIONS_API__ : true ,
45+ __VUE_PROD_DEVTOOLS__ : false
46+ } )
47+ ] ,
4248 resolve : {
4349 alias : {
44- 'vue$ ' : 'vue/dist/vue.esm.js'
50+ 'vue' : 'vue/dist/vue.esm-bundler .js'
4551 } ,
46- extensions : [ '*' , ' .js', '.vue' , '.json' ]
52+ extensions : [ '.js' , '.vue' , '.json' ]
4753 } ,
4854 devServer : {
55+ static : {
56+ directory : path . join ( __dirname )
57+ } ,
4958 historyApiFallback : true ,
50- noInfo : true ,
51- overlay : true
59+ hot : true ,
60+ open : true
5261 } ,
5362 performance : {
5463 hints : false
5564 } ,
56- devtool : '#eval-source-map'
57- }
58-
59- if ( process . env . NODE_ENV === 'production' ) {
60- module . exports . devtool = '#source-map'
61- // http://vue-loader.vuejs.org/en/workflow/production.html
62- module . exports . plugins = ( module . exports . plugins || [ ] ) . concat ( [
63- new webpack . DefinePlugin ( {
64- 'process.env' : {
65- NODE_ENV : '"production"'
66- }
67- } ) ,
68- new webpack . optimize . UglifyJsPlugin ( {
69- sourceMap : true ,
70- compress : {
71- warnings : false
72- }
73- } ) ,
74- new webpack . LoaderOptionsPlugin ( {
75- minimize : true
76- } )
77- ] )
65+ devtool : process . env . NODE_ENV === 'production' ? 'source-map' : 'eval-source-map'
7866}
0 commit comments