@@ -44,7 +44,6 @@ module.exports = (env, params = {}) => {
44
44
const platform = env && ( ( env . android && 'android' ) || ( env . ios && 'ios' ) ) ;
45
45
const tsconfig = 'tsconfig.json' ;
46
46
const projectRoot = params . projectRoot || __dirname ;
47
- const dist = resolve ( projectRoot , nsWebpack . getAppPath ( platform , projectRoot ) ) ;
48
47
const appResourcesFullPath = resolve ( projectRoot , appResourcesPath ) ;
49
48
50
49
if ( ! ! development ) {
@@ -141,12 +140,10 @@ module.exports = (env, params = {}) => {
141
140
// }, {});
142
141
const scssPrepend = `$mdi-fontFamily: ${ platform === 'android' ? 'materialdesignicons-webfont' : 'Material Design Icons' } ;` ;
143
142
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 ) ;
147
144
config . module . rules . splice (
148
- css2jsonLoaderRuleIndex ,
149
- 0 ,
145
+ scssLoaderRuleIndex ,
146
+ 1 ,
150
147
{
151
148
test : / \. s c s s $ / ,
152
149
exclude : / \. m o d u l e \. s c s s $ / ,
@@ -178,29 +175,6 @@ module.exports = (env, params = {}) => {
178
175
]
179
176
}
180
177
) ;
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
- // };
204
178
205
179
config . module . rules . push ( {
206
180
// rules to replace mdi icons and not use nativescript-font-icon
@@ -224,38 +198,29 @@ module.exports = (env, params = {}) => {
224
198
} ) ;
225
199
226
200
// // 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 ) ;
228
202
// 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 } ) ) ;
249
219
250
220
if ( ! ! production ) {
251
221
config . plugins . push (
252
222
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 )
259
224
} )
260
225
) ;
261
226
}
0 commit comments