Bug Report or Feature Request (mark with an x)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Versions.
@angular/cli: 1.2.6 (e)
node: 8.2.1
os: win32 x64
@angular/(all of them): 4.3.3
npm: 5.3.0
node: 8.2.1
Repro steps.
ng new bugdemo
cd bugdemo
ng eject
- Create a very basic Webpack loader called dummy-loader.js:
module.exports = function dummyLoader(source) {
return source.replace("title = 'app'", "title = 'FOOBAR app'");
}
- Edit webpack.config.js, change:
"loader": "@ngtools/webpack"
to:
"loader": ["@ngtools/webpack","./dummy-loader"]
npm start
- Browse to http://localhost:4200/
The log given by the failure.
Actual output: Welcome to app!
Desired functionality.
Expected output: Welcome to FOOBAR app!
Mention any other details that might be useful.
The default project created by ng new generates app.component.html containing this:
Welcome to {{title}}!
and corresponding app.component.ts containing this:
title = 'app';
The dummy-loader.js simply rewrites it to this:
title = 'FOOBAR app';
If we edit webpack.config.js, remove:
"loader": ["@ngtools/webpack","./dummy-loader"]
and replace with:
"loader": ["awesome-typescript-loader", "angular2-template-loader", "./dummy-loader"]
then install the extra modules
npm i awesome-typescript-loader angular2-template-loader
then we get the correct output. So this is definitely a bug in @ngtools/webpack