I wanna replace some code from each typescrpit during webpack compilation. Now I have got something like this:
module: {
rules: [
{
test: /\.ts$/,
enforce: 'pre',
loader: [
{
"loader": "test-loader"
}
]
},
{
test: /\.ts$/,
loader: [
{
"loader": "@ngtools/webpack",
"options": {
"tsConfigPath": "tsconfig.json",
}
}
]
}
]
},
And my test-loader looks like this:
module.exports = function (source, map) {
var callback = this.async();
source = myReplaceFunction(source)
this.cacheable && this.cacheable();
callback(null, source, map);
};
According to this question my loader (test-loader) should be called for each typescript file (and it is). Next loader (@ngtools/webpack) should be operating on modified (by test-loader) typescript files, but isn't, why is that ?
My configuration:
- webpack v3.10.0
- typescript 2.6.2
- node v9.4.0
- @ngtools/webpack v1.10.0-beta.3 (same situation for 1.6.4)
Without enforce: 'pre'
same effect.
I am trying to do something like this, but simpler.