1
1
const path = require ( 'path' ) ,
2
2
fs = require ( 'fs' ) ,
3
-
3
+
4
4
webpack = require ( 'webpack' ) ,
5
5
HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ,
6
6
CordovaHtmlOutputPlugin = require ( './webpack/plugins/CordovaHtmlOutputPlugin.js' ) ,
7
7
UglifyJsPlugin = require ( 'uglifyjs-webpack-plugin' ) ,
8
8
CleanPlugin = require ( 'clean-webpack-plugin' ) ,
9
9
ExtractTextPlugin = require ( "extract-text-webpack-plugin" ) ,
10
-
10
+
11
11
entryFile = path . join ( __dirname , 'src/main.js' ) ,
12
12
devServerPort = 8081
13
13
@@ -16,7 +16,7 @@ let config = function (env) {
16
16
entry : entryFile ,
17
17
18
18
node : { fs : 'empty' } ,
19
-
19
+
20
20
resolve : {
21
21
extensions : [ '.js' , '.json' , '.vue' ] ,
22
22
modules : [ path . join ( __dirname , 'src' ) , 'node_modules' ] ,
@@ -28,17 +28,28 @@ let config = function (env) {
28
28
'components' : path . resolve ( __dirname , 'src/assets/vue/components/' )
29
29
}
30
30
} ,
31
-
31
+
32
32
output : {
33
33
pathinfo : true ,
34
34
devtoolLineToLine : true ,
35
35
filename : '[hash].[name].js' ,
36
36
sourceMapFilename : "[hash].[name].js.map" ,
37
37
path : path . join ( __dirname , 'www' )
38
38
} ,
39
-
39
+
40
40
module : {
41
41
rules : [
42
+ {
43
+ test : / \. j s $ / ,
44
+ exclude : / ( n o d e _ m o d u l e s | b o w e r _ c o m p o n e n t s ) / ,
45
+ use : {
46
+ loader : 'babel-loader' ,
47
+ options : {
48
+ presets : [ 'env' ] ,
49
+ plugins : [ 'transform-runtime' ]
50
+ }
51
+ }
52
+ } ,
42
53
{ test : / \. ( p n g | j p e ? g | g i f ) $ / , loader : 'file-loader' , options : { name : '[name].[ext]?[hash]' } } ,
43
54
{ test : / \. ( w o f f 2 ? | e o t | t t f | o t f | m p 3 | w a v ) ( \? .* ) ? $ / , loader : 'file-loader' , options : { name : '[name].[ext]?[hash]' } } ,
44
55
{ test : / \. s v g $ / , loader : 'url-loader' } ,
@@ -47,7 +58,7 @@ let config = function (env) {
47
58
{ test : / \. v u e $ / , loader : 'vue-loader' }
48
59
]
49
60
} ,
50
-
61
+
51
62
plugins : [
52
63
new webpack . DefinePlugin ( {
53
64
'process.env' : {
@@ -70,7 +81,7 @@ let config = function (env) {
70
81
} )
71
82
]
72
83
}
73
-
84
+
74
85
if ( typeof env === 'undefined' || typeof env . devserver === 'undefined' ) {
75
86
returner . plugins . push ( new CordovaHtmlOutputPlugin ( ) )
76
87
returner . plugins . push ( new ExtractTextPlugin ( "styles.css" ) )
@@ -81,7 +92,7 @@ let config = function (env) {
81
92
} )
82
93
} )
83
94
}
84
-
95
+
85
96
if ( env ) {
86
97
if ( typeof env . devserver !== 'undefined' && env . devserver ) {
87
98
returner . module . rules . push ( {
@@ -117,7 +128,7 @@ let config = function (env) {
117
128
returner . plugins . push ( new UglifyJsPlugin ( ) )
118
129
}
119
130
}
120
-
131
+
121
132
return returner
122
133
}
123
134
0 commit comments