1
1
import path from 'path' ;
2
2
3
3
import FetchStickerDataPlugin from '@signalstickers/fetch-sticker-data-webpack-plugin' ;
4
+ import { CleanWebpackPlugin } from 'clean-webpack-plugin' ;
4
5
import CopyWebpackPlugin from 'copy-webpack-plugin' ;
5
6
// @ts -ignore (No type definitions exist for this package.)
6
7
import FaviconsWebpackPlugin from 'favicons-webpack-plugin' ;
@@ -41,23 +42,20 @@ export default (env: string, argv: any): webpack.Configuration => {
41
42
42
43
// ----- Loaders -------------------------------------------------------------
43
44
44
- // TSLint (Development only).
45
- if ( argv . mode === 'development' ) {
46
- config . module . rules . push ( {
47
- test : / \. ( t s | t s x ) $ / ,
48
- exclude : / n o d e _ m o d u l e s / ,
49
- enforce : 'pre' ,
50
- use : [ {
51
- loader : 'tslint-loader' ,
52
- options : {
53
- configFile : path . resolve ( PKG_ROOT , 'tslint.json' ) ,
54
- tsConfigFile : path . resolve ( PKG_ROOT , 'tsconfig.json' ) ,
55
- formatter : 'codeFrame' ,
56
- typeCheck : true
57
- }
58
- } ]
59
- } ) ;
60
- }
45
+ // ESLint
46
+ config . module . rules . push ( {
47
+ test : / \. ( t s | t s x ) $ / ,
48
+ exclude : / n o d e _ m o d u l e s / ,
49
+ enforce : 'pre' ,
50
+ use : [ {
51
+ loader : 'eslint-loader' ,
52
+ options : {
53
+ emitErrors : true ,
54
+ emitWarning : true ,
55
+ failOnError : argv . mode === 'production'
56
+ }
57
+ } ]
58
+ } ) ;
61
59
62
60
// TypeScript & JavaScript files.
63
61
config . module . rules . push ( {
@@ -164,27 +162,31 @@ export default (env: string, argv: any): webpack.Configuration => {
164
162
config . plugins . push ( new FriendlyErrorsWebpackPlugin ( ) ) ;
165
163
166
164
config . plugins . push ( new MiniCssExtractPlugin ( {
167
- filename : 'styles.css' ,
165
+ filename : 'styles.css'
168
166
} ) ) ;
169
167
}
170
168
171
169
if ( argv . mode === 'production' ) {
172
- config . plugins . push ( new CopyWebpackPlugin ( [ {
173
- // When performing a production build, instruct Webpack to copy all files
174
- // in the 'static' directory into the build directory.
175
- from : path . resolve ( PKG_ROOT , 'static' ) ,
176
- to : path . resolve ( PKG_ROOT , 'dist' )
177
- } ] ) ) ;
170
+ // Delete the build output directory before production builds.
171
+ config . plugins . push ( new CleanWebpackPlugin ( ) ) ;
172
+
173
+ config . plugins . push ( new CopyWebpackPlugin ( {
174
+ patterns : [ {
175
+ // When performing a production build, instruct Webpack to copy all
176
+ // files in the 'static' directory into the build directory.
177
+ from : path . resolve ( PKG_ROOT , 'static' ) ,
178
+ to : path . resolve ( PKG_ROOT , 'dist' )
179
+ } ]
180
+ } ) ) ;
178
181
179
182
config . plugins . push ( new MiniCssExtractPlugin ( {
180
- filename : 'styles-[contenthash].css' ,
183
+ filename : 'styles-[contenthash].css'
181
184
} ) ) ;
182
185
183
186
config . plugins . push ( new webpack . LoaderOptionsPlugin ( {
184
187
minimize : true
185
188
} ) ) ;
186
189
187
-
188
190
config . plugins . push ( new FaviconsWebpackPlugin ( {
189
191
logo : path . resolve ( PKG_ROOT , 'src' , 'assets' , 'favicon.png' ) ,
190
192
cache : true ,
@@ -195,7 +197,7 @@ export default (env: string, argv: any): webpack.Configuration => {
195
197
appDescription : '' ,
196
198
version : '' ,
197
199
developerName : '' ,
198
- developerURL : '' ,
200
+ developerURL : ''
199
201
}
200
202
} ) ) ;
201
203
}
0 commit comments