@@ -44,7 +44,6 @@ module.exports = (env, params = {}) => {
4444 const platform = env && ( ( env . android && 'android' ) || ( env . ios && 'ios' ) ) ;
4545 const tsconfig = 'tsconfig.json' ;
4646 const projectRoot = params . projectRoot || __dirname ;
47- const dist = resolve ( projectRoot , nsWebpack . getAppPath ( platform , projectRoot ) ) ;
4847 const appResourcesFullPath = resolve ( projectRoot , appResourcesPath ) ;
4948
5049 if ( ! ! development ) {
@@ -141,12 +140,10 @@ module.exports = (env, params = {}) => {
141140 // }, {});
142141 const scssPrepend = `$mdi-fontFamily: ${ platform === 'android' ? 'materialdesignicons-webfont' : 'Material Design Icons' } ;` ;
143142
144- const css2jsonLoaderRuleIndex = config . module . rules . findIndex ( r => r . use && r . use . loader === 'css-loader' ) ;
145- const scssLoaderRuleIndex = config . module . rules . findIndex ( r => Array . isArray ( r . use ) && r . use . indexOf ( 'sass-loader' ) !== - 1 ) ;
146- config . module . rules . splice ( scssLoaderRuleIndex , 1 ) ;
143+ const scssLoaderRuleIndex = config . module . rules . findIndex ( ( r ) => r . test && r . test . toString ( ) . indexOf ( 'scss' ) !== - 1 ) ;
147144 config . module . rules . splice (
148- css2jsonLoaderRuleIndex ,
149- 0 ,
145+ scssLoaderRuleIndex ,
146+ 1 ,
150147 {
151148 test : / \. s c s s $ / ,
152149 exclude : / \. m o d u l e \. s c s s $ / ,
@@ -178,29 +175,6 @@ module.exports = (env, params = {}) => {
178175 ]
179176 }
180177 ) ;
181- const indexOfTsLoaderRule = config . module . rules . findIndex ( r => r . loader === 'ts-loader' ) ;
182- config . module . rules [ indexOfTsLoaderRule ] . options . transpileOnly = true ;
183- // config.module.rules[indexOfTsLoaderRule].use.options.getCustomTransformers = (program) => ({
184- // before: [nativeClassTransformer],
185- // });
186- // const mjsRule = {
187- // test: /\.m?js$/,
188- // use: {
189- // loader: 'babel-loader',
190- // options: {
191- // presets: [
192- // [
193- // '@babel/preset-env',
194- // {
195- // useBuiltIns: 'entry',
196- // exclude: ['@babel/plugin-transform-regenerator'],
197- // modules:'commonjs',
198- // },
199- // ],
200- // ],
201- // },
202- // },
203- // };
204178
205179 config . module . rules . push ( {
206180 // rules to replace mdi icons and not use nativescript-font-icon
@@ -224,38 +198,29 @@ module.exports = (env, params = {}) => {
224198 } ) ;
225199
226200 // // we remove default rules
227- config . plugins = config . plugins . filter ( p => [ 'CopyWebpackPlugin ' ] . indexOf ( p . constructor . name ) === - 1 ) ;
201+ config . plugins = config . plugins . filter ( ( p ) => [ 'CopyPlugin ' ] . indexOf ( p . constructor . name ) === - 1 ) ;
228202 // we add our rules
229- config . plugins . unshift (
230- new CopyWebpackPlugin ( [
231- { from : 'fonts/!(ios|android)/**/*' , to : 'fonts' , flatten : true , noErrorOnMissing : true } ,
232- { from : 'fonts/*' , to : 'fonts' , flatten : true , noErrorOnMissing : true } ,
233- { from : `fonts/${ platform } /**/*` , to : 'fonts' , flatten : true , noErrorOnMissing : true } ,
234- {
235- from : '**/*.+(jpg|png)' ,
236- globOptions : {
237- ignore : [ `${ relative ( appPath , appResourcesFullPath ) } /**` ]
238- } ,
239- noErrorOnMissing : true
240- } ,
241- { from : 'assets/**/*' , noErrorOnMissing : true } ,
242- {
243- from : '../node_modules/@mdi/font/fonts/materialdesignicons-webfont.ttf' ,
244- to : 'fonts' ,
245- noErrorOnMissing : true
246- }
247- ] )
248- ) ;
203+ const globOptions = { dot : false , ignore : [ `**/${ relative ( appPath , appResourcesFullPath ) } /**` ] } ;
204+ const context = nsWebpack . Utils . platform . getEntryDirPath ( ) ;
205+ const copyPatterns = [
206+ { context, from : 'fonts/!(ios|android)/**/*' , to : 'fonts/[name][ext]' , noErrorOnMissing : true , globOptions } ,
207+ { context, from : 'fonts/*' , to : 'fonts/[name][ext]' , noErrorOnMissing : true , globOptions } ,
208+ { context, from : `fonts/${ platform } /**/*` , to : 'fonts/[name][ext]' , noErrorOnMissing : true , globOptions } ,
209+ { context, from : '**/*.jpg' , noErrorOnMissing : true , globOptions } ,
210+ { context, from : '**/*.png' , noErrorOnMissing : true , globOptions } ,
211+ { context, from : 'assets/**/*' , noErrorOnMissing : true , globOptions } ,
212+ {
213+ from : 'node_modules/@mdi/font/fonts/materialdesignicons-webfont.ttf' ,
214+ to : 'fonts' ,
215+ globOptions
216+ }
217+ ] ;
218+ config . plugins . unshift ( new CopyWebpackPlugin ( { patterns : copyPatterns } ) ) ;
249219
250220 if ( ! ! production ) {
251221 config . plugins . push (
252222 new ForkTsCheckerWebpackPlugin ( {
253- tsconfig : resolve ( tsconfig ) ,
254- async : false ,
255- useTypescriptIncrementalApi : true ,
256- checkSyntacticErrors : true ,
257- memoryLimit : 4096 ,
258- workers : 1
223+ tsconfig : resolve ( tsconfig )
259224 } )
260225 ) ;
261226 }
0 commit comments