@@ -4,7 +4,7 @@ const CircularDependencyPlugin = require('circular-dependency-plugin');
4
4
// const UnusedFilesWebpackPlugin = require('unused-files-webpack-plugin')['default'];
5
5
6
6
module . exports = function ( grunt ) {
7
- const isProduction = grunt . cli . tasks [ 0 ] === 'release' ;
7
+ const is_production = grunt . cli . tasks [ 0 ] === 'release' ;
8
8
const plugins = [
9
9
new CircularDependencyPlugin ( {
10
10
failOnError : true ,
@@ -31,9 +31,6 @@ module.exports = function (grunt) {
31
31
warnings : false ,
32
32
} ,
33
33
} ) ,
34
- new webpack . DefinePlugin ( {
35
- '__REACT_DEVTOOLS_GLOBAL_HOOK__' : '({ isDisabled: true })'
36
- } ) ,
37
34
// new UnusedFilesWebpackPlugin({
38
35
// patterns: [
39
36
// 'src/javascript/**/*.*',
@@ -42,7 +39,18 @@ module.exports = function (grunt) {
42
39
// }),
43
40
] ;
44
41
45
- if ( ! isProduction ) {
42
+ if ( is_production ) {
43
+ plugins . push (
44
+ new webpack . DefinePlugin ( {
45
+ '__REACT_DEVTOOLS_GLOBAL_HOOK__' : '({ isDisabled: true })'
46
+ } ) ,
47
+ new webpack . DefinePlugin ( {
48
+ 'process.env' : {
49
+ NODE_ENV : JSON . stringify ( 'production' ) ,
50
+ } ,
51
+ } ) ,
52
+ ) ;
53
+ } else {
46
54
plugins . push (
47
55
function ( ) {
48
56
this . plugin ( 'watch-run' , ( watching , callback ) => {
@@ -60,47 +68,42 @@ module.exports = function (grunt) {
60
68
61
69
callback ( ) ;
62
70
} ) ;
63
- }
71
+ } ,
64
72
) ;
65
73
}
66
74
67
75
const common_options = {
68
76
node : {
69
77
fs : 'empty' ,
70
78
} ,
71
- // devtool: isProduction ? 'source-map' : 'cheap-source-map',
79
+ // devtool: is_production ? 'source-map' : 'cheap-source-map',
72
80
cache : true ,
73
81
stats : {
74
82
chunks : false ,
75
83
} ,
76
84
entry : {
77
- [ isProduction ? 'binary.min' :'binary' ] : './src/javascript' ,
85
+ [ is_production ? 'binary.min' :'binary' ] : './src/javascript' ,
78
86
} ,
79
87
output : {
80
88
path : path . resolve ( __dirname , `../${ global . dist } /js/` ) ,
81
89
filename : '[name].js' ,
82
90
chunkFilename : '[name]_[chunkhash].min.js' ,
83
- publicPath : `${ isProduction || grunt . file . exists ( `${ process . cwd ( ) } /scripts/CNAME` ) ? '' : '/binary-static' } ${ global . branch ? `/${ global . branch_prefix } ${ global . branch } ` : '' } /js/` ,
91
+ publicPath : `${ is_production || grunt . file . exists ( `${ process . cwd ( ) } /scripts/CNAME` ) ? '' : '/binary-static' } ${ global . branch ? `/${ global . branch_prefix } ${ global . branch } ` : '' } /js/` ,
92
+ } ,
93
+ resolve : {
94
+ extensions : [ '.js' , '.jsx' ] ,
84
95
} ,
85
96
module : {
86
97
loaders : [
87
98
{
88
- test : / \. j s $ / ,
89
- exclude : / n o d e _ m o d u l e s / ,
90
- loader : 'babel-loader' ,
91
- query : {
92
- presets : [ 'env' ] ,
93
- compact : false ,
94
- } ,
95
- } , {
96
- test : / \. j s x $ / ,
99
+ test : / \. j s x ? $ / ,
97
100
exclude : / n o d e _ m o d u l e s / ,
98
101
loader : 'babel-loader' ,
99
102
query : {
100
- presets : [ 'react' , 'env '] ,
103
+ presets : [ 'env' , 'react '] ,
101
104
plugins : [
102
105
'transform-object-rest-spread' ,
103
- 'transform-class-properties'
106
+ 'transform-class-properties' ,
104
107
] ,
105
108
compact : false ,
106
109
} ,
0 commit comments