File tree 5 files changed +113
-4
lines changed
5 files changed +113
-4
lines changed Original file line number Diff line number Diff line change 6
6
"scripts" : {
7
7
"test" : " jest" ,
8
8
"watch" : " webpack --watch" ,
9
- "build" : " webpack --mode production " ,
10
- "start" : " webpack-dev-server --open" ,
9
+ "build" : " NODE_ENV=production webpack --config webpack.prod.js " ,
10
+ "start" : " NODE_ENV=development webpack-dev-server --open --config webpack.dev.js " ,
11
11
"predeploy" : " npm run build" ,
12
12
"deploy" : " gh-pages -d dist"
13
13
},
45
45
"svg-url-loader" : " ^2.3.3" ,
46
46
"webpack" : " ^4.32.0" ,
47
47
"webpack-cli" : " ^3.3.2" ,
48
- "webpack-dev-server" : " ^3.4.1"
48
+ "webpack-dev-server" : " ^3.4.1" ,
49
+ "webpack-merge" : " ^4.2.1"
49
50
}
50
51
}
Original file line number Diff line number Diff line change
1
+ const path = require ( 'path' ) ;
2
+ const Dotenv = require ( 'dotenv-webpack' ) ;
3
+ const MiniCssExtractPlugin = require ( 'mini-css-extract-plugin' ) ;
4
+ const postcssCustomProperties = require ( 'postcss-custom-properties' ) ;
5
+ const autoprefixer = require ( 'autoprefixer' ) ;
6
+
7
+ module . exports = {
8
+ context : path . resolve ( __dirname , "src" ) ,
9
+ entry : "./index.js" ,
10
+
11
+ output : {
12
+ filename : "main.js" ,
13
+ path : path . join ( __dirname , 'dist' )
14
+ } ,
15
+ module : {
16
+ rules : [
17
+ {
18
+ test : / \. ( j s | j s x ) $ / ,
19
+ exclude : / n o d e _ m o d u l e s / ,
20
+ use : [
21
+ {
22
+ loader : "babel-loader"
23
+ }
24
+ ]
25
+ } ,
26
+ {
27
+ test : / \. s c s s $ / ,
28
+ use : [
29
+ {
30
+ loader : MiniCssExtractPlugin . loader ,
31
+ options : {
32
+ hmr : process . env . NODE_ENV === 'development' ,
33
+ } ,
34
+ } ,
35
+ 'css-loader' ,
36
+ {
37
+ loader : 'postcss-loader' ,
38
+ options : {
39
+ ident : 'postcss' ,
40
+ plugins : ( ) => [
41
+ postcssCustomProperties ( ) ,
42
+ autoprefixer
43
+ ]
44
+ }
45
+ } ,
46
+ 'sass-loader'
47
+ ] ,
48
+ } ,
49
+ {
50
+ test : / \. s v g / ,
51
+ use : {
52
+ loader : 'svg-url-loader' ,
53
+ options : { }
54
+ }
55
+ } ,
56
+ {
57
+ test : / \. ( h t m l ) $ / ,
58
+ use : {
59
+ loader : 'file-loader' ,
60
+ options : {
61
+ name : '[name].[ext]'
62
+ }
63
+ }
64
+ }
65
+ ] ,
66
+ } ,
67
+ plugins : [
68
+ new Dotenv ( ) ,
69
+ new MiniCssExtractPlugin ( {
70
+ filename : '[name].css' ,
71
+ chunkFilename : '[id].css' ,
72
+ } ) ,
73
+ ]
74
+ } ;
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ const postcssCustomProperties = require('postcss-custom-properties');
5
5
const autoprefixer = require ( 'autoprefixer' ) ;
6
6
7
7
module . exports = {
8
- context : __dirname + "/ src",
8
+ context : path . resolve ( __dirname , " src") ,
9
9
entry : "./index.js" ,
10
10
11
11
output : {
Original file line number Diff line number Diff line change
1
+ const merge = require ( 'webpack-merge' ) ;
2
+ const common = require ( './webpack.common.js' ) ;
3
+ const path = require ( 'path' ) ;
4
+
5
+ module . exports = merge ( common , {
6
+ mode : 'development' ,
7
+ devtool : 'source-map' ,
8
+ devServer : {
9
+ hot : true ,
10
+ inline : true ,
11
+ index : path . join ( __dirname , 'index.html' )
12
+ } ,
13
+ module : {
14
+ rules : [
15
+ {
16
+ test : / \. ( j s | j s x ) $ / ,
17
+ exclude : / n o d e _ m o d u l e s / ,
18
+ use : [
19
+ {
20
+ loader : "react-hot-loader/webpack"
21
+ }
22
+ ]
23
+ }
24
+ ]
25
+ }
26
+ } ) ;
27
+
28
+ console . log ( 'Env is ' , process . env . NODE_ENV ) ;
Original file line number Diff line number Diff line change
1
+ const merge = require ( 'webpack-merge' ) ;
2
+ const common = require ( './webpack.common.js' ) ;
3
+
4
+ module . exports = merge ( common , {
5
+ mode : 'production' ,
6
+ } ) ;
You can’t perform that action at this time.
0 commit comments