nippur72 / ifdef-loader

Webpack loader for JavaScript/TypeScript conditional compilation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ifdef-loader not reflecting in main.js

naveenakn7122 opened this issue · comments

hi @nippur72
i installed ifdef-loader 2.3.0 to understand this package, but i see that its not really removing code in main.js , my changes below. logs during build clearly sharing message, but not reflecting main.js. can you please let me know what has went wrong here.

///// custom-webpack.config.js ///////

const opts = {
myVal: 1,
"ifdef-verbose": true, // add this for verbose output
"ifdef-triple-slash": true, // add this to use double slash comment instead of default triple slash
"ifdef-fill-with-blanks": true, // add this to remove code with blank spaces instead of "//" comments
"ifdef-uncomment-prefix": "// #code " // add this to uncomment code starting with "// #code "
};
module.exports = {
module: {
rules: [
{
test: /.ts?$/,
exclude: /node_modules/,
use: [
{ loader: "ts-loader" },
{ loader: "ifdef-loader", options: opts }
]
},
]
}

////// app.component.ts ///////

export class AppComponent {
/// #if myVal==2
title: string = 'preprocessorexmple 1';
/// #endif
/// #if myVal!=2
title1: string = 'preprocessorexmple ';
/// #endif
constructor() {
}
}

// verbose
ng build
⠦ Generating browser application bundles (phase: building)...#if block lines [9-11]: Condition 'myVal==2' is FALSE. Excluding everything (src\app\app.component.ts)
#if block lines [12-14]: Condition 'myVal!=2' is TRUE. Including lines [12-14] (src\app\app.component.ts)

///// main.js generated file //////
} }
class AppComponent {
/// #endif
constructor() {
/// #if myVal==2
this.title = 'preprocessorexmple 1';
/// #endif
/// #if myVal!=2
this.title1 = 'preprocessorexmple ';
}
}