2424 * @contact : n8tz.js@gmail.com
2525 */
2626
27- var wpInherit = require ( 'webpack-inherit ' ) ;
27+ var lPack = require ( 'layer-pack ' ) ;
2828var fs = require ( "fs" ) ;
2929var webpack = require ( "webpack" ) ;
3030var path = require ( "path" ) ;
@@ -35,35 +35,35 @@ const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
3535var autoprefixer = require ( 'autoprefixer' ) ;
3636
3737
38- const wpiCfg = wpInherit . getConfig ( ) ,
39- isExcluded = wpInherit . isFileExcluded ( ) ;
38+ const lpackCfg = lPack . getConfig ( ) ,
39+ isExcluded = lPack . isFileExcluded ( ) ;
4040module . exports = [
4141 {
42- mode : wpiCfg . vars . production ? "production" : "development" ,
42+ mode : lpackCfg . vars . production ? "production" : "development" ,
4343
4444 // The jsx App entry point
4545 entry : {
4646
47- [ wpiCfg . vars . rootAlias ] : [
48- ...( wpiCfg . vars . devServer && [ 'webpack/hot/dev-server' ] || [ ] ) ,
47+ [ lpackCfg . vars . rootAlias ] : [
48+ ...( lpackCfg . vars . devServer && [ 'webpack/hot/dev-server' ] || [ ] ) ,
4949
50- wpiCfg . vars . entryPoint ?
51- wpiCfg . vars . entryPoint
50+ lpackCfg . vars . entryPoint ?
51+ lpackCfg . vars . entryPoint
5252 :
53- wpiCfg . vars . rootAlias + "/index" // default to 'App'
53+ lpackCfg . vars . rootAlias + "/index" // default to 'App'
5454 ]
5555 } ,
5656
5757 // The resulting build
5858 output : {
59- path : wpInherit . getHeadRoot ( ) + "/" + ( wpiCfg . vars . targetDir || 'dist' ) ,
59+ path : lPack . getHeadRoot ( ) + "/" + ( lpackCfg . vars . targetDir || 'dist' ) ,
6060 filename : "[name].js" ,
6161 publicPath : "/" ,
6262 "libraryTarget" : "commonjs-module"
6363 } ,
6464
6565 // add sourcemap in a dedicated file (.map)
66- devtool : ! wpiCfg . vars . production && 'source-map' ,
66+ devtool : ! lpackCfg . vars . production && 'source-map' ,
6767
6868 // required files resolving options
6969 resolve : {
@@ -74,21 +74,21 @@ module.exports = [
7474 ".scss" ,
7575 ".css" ,
7676 ] ,
77- alias : wpiCfg . vars . devServer && {
77+ alias : lpackCfg . vars . devServer && {
7878 'react-dom' : '@hot-loader/react-dom'
7979 } ,
8080 } ,
8181
8282 // Global build plugin & option
8383 plugins : (
8484 [
85- wpInherit . plugin ( ) ,
85+ lPack . plugin ( ) ,
8686
8787 //new HardSourceWebpackPlugin(),
88- ...( ( wpiCfg . vars . indexTpl || wpiCfg . vars . HtmlWebpackPlugin ) && [
88+ ...( ( lpackCfg . vars . indexTpl || lpackCfg . vars . HtmlWebpackPlugin ) && [
8989 new HtmlWebpackPlugin ( {
90- template : wpiCfg . vars . indexTpl || ( wpiCfg . vars . rootAlias + '/index.html.tpl' ) ,
91- ...wpiCfg . vars . HtmlWebpackPlugin
90+ template : lpackCfg . vars . indexTpl || ( lpackCfg . vars . rootAlias + '/index.html.tpl' ) ,
91+ ...lpackCfg . vars . HtmlWebpackPlugin
9292 } )
9393 ] || [ ]
9494 ) ,
@@ -97,17 +97,17 @@ module.exports = [
9797 ] || [ ]
9898 ) ,
9999
100- ...( wpiCfg . vars . production && [
100+ ...( lpackCfg . vars . production && [
101101 new webpack . DefinePlugin ( {
102102 'process.env' : {
103103 'NODE_ENV' : JSON . stringify ( 'production' )
104104 }
105105 } ) ,
106106 new BundleAnalyzerPlugin ( {
107107 analyzerMode : 'static' ,
108- reportFilename : './' + wpiCfg . vars . rootAlias + '.stats.html' ,
108+ reportFilename : './' + lpackCfg . vars . rootAlias + '.stats.html' ,
109109 openAnalyzer : false ,
110- ...wpiCfg . vars . BundleAnalyzerPlugin
110+ ...lpackCfg . vars . BundleAnalyzerPlugin
111111 } )
112112
113113 ] || [ new webpack . NamedModulesPlugin ( ) ] )
@@ -118,7 +118,7 @@ module.exports = [
118118 // the requirable files and what manage theirs parsing
119119 module : {
120120 rules : [
121- ...( wpiCfg . vars . devServer && [
121+ ...( lpackCfg . vars . devServer && [
122122 {
123123 test : / \. j s x ? $ / ,
124124 exclude : isExcluded ,
@@ -129,11 +129,11 @@ module.exports = [
129129 ] || [ ] ) ,
130130 {
131131 test : / \. j s x ? $ / ,
132- exclude : wpiCfg . vars . babelInclude
132+ exclude : lpackCfg . vars . babelInclude
133133 ?
134134 (
135135 includeRE => ( { test : path => ( isExcluded . test ( path ) && ! includeRE . test ( path ) ) } )
136- ) ( new RegExp ( wpiCfg . vars . babelInclude ) )
136+ ) ( new RegExp ( lpackCfg . vars . babelInclude ) )
137137 :
138138 isExcluded ,
139139 use : [
@@ -144,7 +144,7 @@ module.exports = [
144144 presets : [
145145 [ '@babel/preset-env' ,
146146 {
147- ...( wpiCfg . vars . babelPreset || { } )
147+ ...( lpackCfg . vars . babelPreset || { } )
148148 } ] ,
149149 '@babel/preset-react'
150150 ] ,
@@ -154,23 +154,23 @@ module.exports = [
154154 "loose" : true
155155 } ] ,
156156 [ "@babel/plugin-transform-runtime" , { } ] ,
157- ...( wpiCfg . vars . devServer && [ [ require . resolve ( "react-hot-loader/babel" ) , { } ] ] || [ ] ) ,
157+ ...( lpackCfg . vars . devServer && [ [ require . resolve ( "react-hot-loader/babel" ) , { } ] ] || [ ] ) ,
158158 ]
159159 }
160160 } ,
161161 ]
162162 } ,
163163 {
164164 test : / \. ( s c s s | c s s ) $ / ,
165- use : wpiCfg . vars . extractCss ?
165+ use : lpackCfg . vars . extractCss ?
166166 [
167167 {
168168 loader : MiniCssExtractPlugin . loader ,
169169 options : {
170170 // you can specify a publicPath here
171171 // by default it uses publicPath in webpackOptions.output
172172 publicPath : '../' ,
173- hmr : ! wpiCfg . vars . production ,
173+ hmr : ! lpackCfg . vars . production ,
174174 } ,
175175 } ,
176176 { loader : 'css-loader' , options : { importLoaders : 1 } } ,
@@ -196,7 +196,7 @@ module.exports = [
196196 loader : "sass-loader" ,
197197 options : {
198198 minimize : true ,
199- importer : wpInherit . plugin ( ) . sassImporter ( ) ,
199+ importer : lPack . plugin ( ) . sassImporter ( ) ,
200200 sourceMaps : true ,
201201 }
202202 }
@@ -225,7 +225,7 @@ module.exports = [
225225 {
226226 loader : "sass-loader" ,
227227 options : {
228- importer : wpInherit . plugin ( ) . sassImporter ( ) ,
228+ importer : lPack . plugin ( ) . sassImporter ( ) ,
229229 sourceMaps : true
230230 }
231231 }
0 commit comments