1- var path = require ( ' path' )
1+ var path = require ( " path" )
22
3- var webpack = require ( 'webpack' )
4- var ExtractTextPlugin = require ( 'extract-text-webpack-plugin' )
5- var deepExtend = require ( 'deep-extend' )
6- var autoprefixer = require ( 'autoprefixer' )
7- const { gitDescribeSync} = require ( 'git-describe' )
3+ var webpack = require ( "webpack" )
4+ var ExtractTextPlugin = require ( "extract-text-webpack-plugin" )
5+ var UglifyJsPlugin = require ( "uglifyjs-webpack-plugin" )
6+ var deepExtend = require ( "deep-extend" )
7+ var autoprefixer = require ( "autoprefixer" )
8+ const { gitDescribeSync} = require ( "git-describe" )
89
9- var pkg = require ( ' ./package.json' )
10+ var pkg = require ( " ./package.json" )
1011
1112let gitInfo
1213
1314try {
1415 gitInfo = gitDescribeSync ( __dirname )
1516} catch ( e ) {
1617 gitInfo = {
17- hash : ' noGit' ,
18+ hash : " noGit" ,
1819 dirty : false
1920 }
2021}
2122
22- var loadersByExtension = require ( ' ./build-tools/loadersByExtension' )
23+ var loadersByExtension = require ( " ./build-tools/loadersByExtension" )
2324
2425module . exports = function ( options ) {
2526
@@ -35,39 +36,40 @@ module.exports = function(options) {
3536 } , options . _special )
3637
3738 var loadersMap = {
38- 'js(x)?' : {
39- loader : 'babel?retainLines=true' ,
40- include : [ path . join ( __dirname , 'src' ) ] ,
39+ "js(x)?" : {
40+ loader : "babel?retainLines=true" ,
41+ include : [
42+ path . join ( __dirname , "src" ) ,
43+ path . join ( __dirname , "node_modules" , "object-assign-deep" )
44+ ] ,
4145 } ,
42- ' json' : ' json-loader' ,
43- ' txt|yaml' : ' raw-loader' ,
44- ' png|jpg|jpeg|gif|svg' : specialOptions . disableAssets ? ' null-loader' : ' url-loader?limit=10000' ,
45- ' woff|woff2' : specialOptions . disableAssets ? ' null-loader' : ' url-loader?limit=100000' ,
46- ' ttf|eot' : specialOptions . disableAssets ? ' null-loader' : ' file-loader' ,
46+ " json" : " json-loader" ,
47+ " txt|yaml" : " raw-loader" ,
48+ " png|jpg|jpeg|gif|svg" : specialOptions . disableAssets ? " null-loader" : " url-loader?limit=10000" ,
49+ " woff|woff2" : specialOptions . disableAssets ? " null-loader" : " url-loader?limit=100000" ,
50+ " ttf|eot" : specialOptions . disableAssets ? " null-loader" : " file-loader" ,
4751 "worker.js" : [ "worker-loader?inline=true" , "babel" ]
4852 }
4953
5054 var plugins = [ ]
5155
5256 if ( specialOptions . separateStylesheets ) {
53- plugins . push ( new ExtractTextPlugin ( ' [name].css' + ( specialOptions . longTermCaching ? ' ?[contenthash]' : '' ) , {
57+ plugins . push ( new ExtractTextPlugin ( " [name].css" + ( specialOptions . longTermCaching ? " ?[contenthash]" : "" ) , {
5458 allChunks : true
5559 } ) )
5660 }
5761
5862 if ( specialOptions . minimize ) {
5963
6064 plugins . push (
61- new webpack . optimize . UglifyJsPlugin ( {
62- compressor : {
63- warnings : false
64- }
65+ new UglifyJsPlugin ( {
66+ sourceMap : true ,
6567 } ) ,
6668 new webpack . optimize . DedupePlugin ( )
6769 )
6870
6971 if ( specialOptions . html ) {
70- var HtmlWebpackPlugin = require ( ' html-webpack-plugin' ) ;
72+ var HtmlWebpackPlugin = require ( " html-webpack-plugin" )
7173 plugins . push ( new HtmlWebpackPlugin ( ) )
7274 }
7375
@@ -76,34 +78,34 @@ module.exports = function(options) {
7678
7779 plugins . push (
7880 new webpack . DefinePlugin ( {
79- ' process.env' : {
80- NODE_ENV : specialOptions . minimize ? JSON . stringify ( ' production' ) : null ,
81+ " process.env" : {
82+ NODE_ENV : specialOptions . minimize ? JSON . stringify ( " production" ) : null ,
8183 WEBPACK_INLINE_STYLES : ! Boolean ( specialOptions . separateStylesheets )
8284 } ,
83- ' buildInfo' : JSON . stringify ( {
85+ " buildInfo" : JSON . stringify ( {
8486 PACKAGE_VERSION : pkg . version ,
8587 GIT_COMMIT : gitInfo . hash ,
8688 GIT_DIRTY : gitInfo . dirty
8789 } )
8890 } ) )
8991
90- var cssLoader = ' css-loader!postcss-loader'
92+ var cssLoader = " css-loader!postcss-loader"
9193
9294 var completeStylesheetLoaders = deepExtend ( {
93- ' css' : cssLoader ,
94- ' less' : cssLoader + '!' + ' less-loader' ,
95+ " css" : cssLoader ,
96+ " less" : cssLoader + "!" + " less-loader" ,
9597 } , specialOptions . stylesheetLoaders )
9698
9799 if ( specialOptions . cssModules ) {
98- cssLoader = cssLoader + ' ?module' + ( specialOptions . minimize ? '' : ' &localIdentName=[path][name]---[local]---[hash:base64:5]' )
100+ cssLoader = cssLoader + " ?module" + ( specialOptions . minimize ? "" : " &localIdentName=[path][name]---[local]---[hash:base64:5]" )
99101 }
100102
101103 Object . keys ( completeStylesheetLoaders ) . forEach ( function ( ext ) {
102104 var ori = completeStylesheetLoaders [ ext ]
103105 if ( specialOptions . separateStylesheets ) {
104- completeStylesheetLoaders [ ext ] = ExtractTextPlugin . extract ( ' style-loader' , ori )
106+ completeStylesheetLoaders [ ext ] = ExtractTextPlugin . extract ( " style-loader" , ori )
105107 } else {
106- completeStylesheetLoaders [ ext ] = ' style-loader!' + ori
108+ completeStylesheetLoaders [ ext ] = " style-loader!" + ori
107109 }
108110 } )
109111
@@ -115,51 +117,51 @@ module.exports = function(options) {
115117 delete options . module . loaders
116118 }
117119
118- var completeConfig = deepExtend ( {
120+ var completeConfig = deepExtend ( {
119121 entry : { } ,
120122
121123 output : {
122- path : path . join ( __dirname , ' dist' ) ,
123- publicPath : '/' ,
124- filename : ' [name].js' ,
125- chunkFilename : ' [id].[chunkhash].js'
124+ path : path . join ( __dirname , " dist" ) ,
125+ publicPath : "/" ,
126+ filename : " [name].js" ,
127+ chunkFilename : " [id].[chunkhash].js"
126128 } ,
127129
128- target : ' web' ,
130+ target : " web" ,
129131
130132 // yaml-js has a reference to `fs`, this is a workaround
131133 node : {
132- fs : ' empty'
134+ fs : " empty"
133135 } ,
134136
135137 module : {
136138 loaders : loaders ,
137139 } ,
138140
139141 resolveLoader : {
140- root : path . join ( __dirname , ' node_modules' ) ,
142+ root : path . join ( __dirname , " node_modules" ) ,
141143 } ,
142144
143145 externals : {
144- ' buffertools' : true // json-react-schema/deeper depends on buffertools, which fails.
146+ " buffertools" : true // json-react-schema/deeper depends on buffertools, which fails.
145147 } ,
146148
147149 resolve : {
148- root : path . join ( __dirname , ' ./src' ) ,
149- modulesDirectories : [ ' node_modules' ] ,
150- extensions : [ '' , ' .js' , ' .jsx' , ' json' ] ,
151- packageAlias : ' browser' ,
150+ root : path . join ( __dirname , " ./src" ) ,
151+ modulesDirectories : [ " node_modules" ] ,
152+ extensions : [ "" , " .js" , " .jsx" , " json" ] ,
153+ packageAlias : " browser" ,
152154 alias : {
153- ' react' : path . resolve ( __dirname , ' node_modules' , ' react' ) ,
154- ' swagger-jx' : path . resolve ( __dirname , ' node_modules' , ' swagger-jx' )
155+ " react" : path . resolve ( __dirname , " node_modules" , " react" ) ,
156+ " swagger-jx" : path . resolve ( __dirname , " node_modules" , " swagger-jx" )
155157 }
156158 } ,
157159
158160 postcss : function ( ) {
159161 return [ autoprefixer ]
160162 } ,
161163
162- devtool : specialOptions . sourcemaps ? ' nosource-source-map' : null ,
164+ devtool : specialOptions . sourcemaps ? " nosource-source-map" : null ,
163165
164166 } , options )
165167
0 commit comments