Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double rules in webpack-configs/common.js #34

Closed
alexprykhodko opened this issue Apr 12, 2020 · 1 comment
Closed

Double rules in webpack-configs/common.js #34

alexprykhodko opened this issue Apr 12, 2020 · 1 comment

Comments

@alexprykhodko
Copy link

The module.rules in node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/common.js has the following lines after installing new npm packages with ng-cli-pug-loader installed:

rules: [ { test: /.(pug|jade)$/, exclude: /.(include|partial).(pug|jade)$/, use: [ { loader: "apply-loader" }, { loader: "pug-loader" } ] }, { test: /.(include|partial).(pug|jade)$/, loader: "pug-loader" }, { test: /\.(pug|jade)$/, exclude: /\.(include|partial)\.(pug|jade)$/, use: [ { loader: "apply-loader" }, { loader: "pug-loader" } ] }, { test: /\.(include|partial)\.(pug|jade)$/, loader: "pug-loader" },

The resulting double rules produce errors as seen in pugjs/pug-loader#120

The issue is corrected by changing the rules to:

rules: [ { test: /\.(pug|jade)$/, exclude: /\.(include|partial)\.(pug|jade)$/, use: [ { loader: "apply-loader" }, { loader: "pug-loader" } ] }, { test: /\.(include|partial)\.(pug|jade)$/, loader: "pug-loader" },

(Note the correct escaping)

On the very first run of 'ng-add-pug-loader.js', the newly added rule in module.rules has bad escaping, which results in adding the new rule on the consecutive runs of 'ng-add-pug-loader.js':

{ test: /.(pug|jade)$/, exclude: /.(include|partial).(pug|jade)$/, use: [ { loader: "apply-loader" }, { loader: "pug-loader" } ] }, { test: /.(include|partial).(pug|jade)$/, loader: "pug-loader" }

Steps to reproduce:

  1. Run ng new my-app.
  2. Run ng add ng-cli-pug-loader.
  3. Rename 'app.component.html' to 'app.component.pug'.
  4. Run ng add @angular/material

Version info:

Angular CLI: 9.1.1
Node: 13.12.0

@danguilherme
Copy link
Owner

This project is no longer maintained. Check out ngx-pug-builders to add support to pug files to your Angular project.

@danguilherme danguilherme closed this as not planned Won't fix, can't repro, duplicate, stale Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants