1
1
'use strict' ;
2
+ const path = require ( 'path' ) ;
2
3
const webpack = require ( 'webpack' ) ;
3
4
const WebpackBar = require ( 'webpackbar' ) ;
4
5
const CaseSensitivePathsPlugin = require ( 'case-sensitive-paths-webpack-plugin' ) ;
5
6
const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
6
7
const CopyWebpackPlugin = require ( 'copy-webpack-plugin' ) ;
7
- const env = require ( '../env' ) ;
8
+ const env = require ( '../../ env' ) ;
8
9
9
10
module . exports = {
10
11
context : env . rootPath ,
11
12
entry : {
12
- index : [ './src' ]
13
+ index : [ './src' ] ,
13
14
} ,
14
15
output : {
15
16
path : env . distPath ,
16
17
filename : '[name].[hash:8].js' ,
17
18
publicPath : '/' ,
18
- chunkFilename : '[name].[hash:8].chunk.js'
19
+ chunkFilename : '[name].[hash:8].chunk.js' ,
19
20
} ,
20
- externals : { } ,
21
21
resolve : {
22
22
extensions : [ '.js' , '.jsx' , '.ts' , '.tsx' , '.less' , '.json' ] ,
23
23
alias : {
24
- '@' : env . srcPath
25
- }
24
+ '@' : env . srcPath ,
25
+ } ,
26
26
} ,
27
27
module : {
28
28
rules : [
@@ -33,10 +33,11 @@ module.exports = {
33
33
{
34
34
loader : 'babel-loader' ,
35
35
options : {
36
- rootMode : 'upward'
37
- }
38
- }
39
- ]
36
+ rootMode : 'upward' ,
37
+ cacheDirectory : true ,
38
+ } ,
39
+ } ,
40
+ ] ,
40
41
} ,
41
42
{
42
43
test : / \. ( p n g | j p g | g i f ) $ / ,
@@ -45,10 +46,10 @@ module.exports = {
45
46
loader : 'url-loader' ,
46
47
options : {
47
48
limit : 10000 ,
48
- name : 'static/[name].[hash:8].[ext]'
49
- }
50
- }
51
- ]
49
+ name : 'static/[name].[hash:8].[ext]' ,
50
+ } ,
51
+ } ,
52
+ ] ,
52
53
} ,
53
54
{
54
55
test : / \. ( t t f | e o t | s v g ) ( \? v = [ 0 - 9 ] \. [ 0 - 9 ] \. [ 0 - 9 ] ) ? $ / ,
@@ -57,47 +58,47 @@ module.exports = {
57
58
loader : 'file-loader' ,
58
59
options : {
59
60
limit : 8192 ,
60
- name : 'fonts/[name].[hash:8].[ext]'
61
- }
62
- }
63
- ]
64
- }
65
- ]
61
+ name : 'fonts/[name].[hash:8].[ext]' ,
62
+ } ,
63
+ } ,
64
+ ] ,
65
+ } ,
66
+ ] ,
66
67
} ,
67
68
optimization : {
68
69
runtimeChunk : {
69
- name : ( entrypoint ) => `runtime.${ entrypoint . name } `
70
+ name : entrypoint => `runtime.${ entrypoint . name } ` ,
70
71
} ,
71
72
splitChunks : {
72
73
cacheGroups : {
73
74
vendors : {
74
75
name : 'vendors' ,
75
76
chunks : 'initial' ,
76
77
test : / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] / ,
77
- priority : 30
78
+ priority : 30 ,
78
79
} ,
79
80
asyncVendors : {
80
81
name : 'async-vendors' ,
81
82
chunks : 'async' ,
82
83
test : / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] / ,
83
- priority : 20
84
+ priority : 20 ,
84
85
} ,
85
86
asyncCommon : {
86
87
name : 'async-common' ,
87
88
chunks : 'async' ,
88
89
minChunks : 2 ,
89
90
priority : 10 ,
90
- reuseExistingChunk : true
91
+ reuseExistingChunk : true ,
91
92
} ,
92
93
default : {
93
94
name : 'common' ,
94
95
chunks : 'all' ,
95
96
minChunks : 2 ,
96
97
priority : - 20 ,
97
- reuseExistingChunk : true
98
- }
99
- }
100
- }
98
+ reuseExistingChunk : true ,
99
+ } ,
100
+ } ,
101
+ } ,
101
102
} ,
102
103
plugins : [
103
104
new WebpackBar ( ) ,
@@ -107,13 +108,13 @@ module.exports = {
107
108
[
108
109
{
109
110
from : env . publicPath ,
110
- to : env . distPath
111
- }
111
+ to : env . distPath ,
112
+ } ,
112
113
] ,
113
- { ignore : [ '**/.*' ] }
114
+ { ignore : [ '**/.*' ] } ,
114
115
) ,
115
116
new HtmlWebpackPlugin ( {
116
- template : ` ${ env . publicPath } / index.html`
117
- } )
118
- ]
117
+ template : path . resolve ( env . publicPath , ' index.html' ) ,
118
+ } ) ,
119
+ ] ,
119
120
} ;
0 commit comments