You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry for not providing template information but I only have my phone available (and there's no critical info either).
Is there some in-the-works support for jade? The related issues/PR 's were closed but no real solution was provided. What can be done to have support for this?
Reacted by Niklas, sebastian krämer, Tobias, Jay Liu, Stas Vladykov, Tasos Bekos, Sergio Álvarez, Randall Meeker, Maksym Bugai, Sijmen and 35 more
So you guys closed #996 and #968 in favor of #40, then closed #40 with no specific ending, then closed the efforts in #1433 and #626 because you changed to webpack and here we are with no answers.
Sorry, I'm not trying to be annoying, specially when I see a lot of hate on recent issues with bugs regarding latest TS/Angular/CLI combinations. I can understand error because we are humans, I can understand time because we need to sleep and have to live, but I do hate purposeful indifference, just because its not your problem. I'm open to work myself on the CLI on a new PR, but I do need guidance, and that really starts at least with a single answer in a timelapse of 10 days. Nevertheless, thank you for your efforts.
Reacted by Tobias, Ignat S., Randall Meeker, Yaroslav Senishyn, krasevych, Valdis Zobēla, Thibaut CARCENAC, Vadim Zhamkov, Ivaylo Ivanov, Marcell Kiss and 17 more
Reacted by Niklas, Randall Meeker, krasevych, Fernando Buccella, Rǎo-bè, Aliaksandr Zhukau, Jean-Matthieu BARBIER, Josué A. de Lima, Piotr Piech, ❁ Mohammed Matar ❁ and 1 more
My team is using pug-cli with --watch at the moment for the same results. However, I would prefer jade to be part of the webpack bundling itself. I'll submit a PR if I have time to figure out how to set it up.
Heya @ShadowManu, we're not trying to be indifferent and I'm sorry that the jade support has fallen to the wayside.
I can't say jade/pug support is a big on our radars right now to be honest. If you can get a PR to work I'm happy to review it, but bear in mind that it needs to have tests and documentation.
Ideally we'd also support initializing a project with pug like we do with sass (ng new sassy-project --style=sass), or setting the default template language (ng set defaults.styleExt scss) but to be honest that's further down the road.
@kingsdevelopment@filipesilva I've worked a little with some time I had on this, but got blocked on how to make the tests pass (specially on the time they take). I'll have a second try tomorrow.
@nvrossett not that I have knowledge of it. And probably should be on a different PR/issue.
I just wanted to throw my support behind @tycho01 's pug-plugin-ng and pug-ng-html-loader. I used them to use pug with the Angular Class seed, and it really cleans up the syntax and makes development with Angular2 and pug very pleasant. I recommend checking it out:
@TaylorDennisLee: thanks. note that for Webpack 2 it should work without the additional loader as well now, see the readme.
Edit: note that original pug syntax is not harmed/disabled; the plugin just patches the lexer to ensure this cleaner more natural (perspective: HTML) option is parsed correctly as well.
@mbonski
Your example is really close.
First install pug and pug-loader and use this example code.
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: require('pug-loader!./app.component.pug')(),
styleUrls: ['app.component.scss']
})
export class AppComponent {
title = 'app works!';
}
The only difference is template: require('./app.component.pug')
To => template: require('pug-loader!./app.component.pug')()
You may also need to add the following into typings.d.ts
// telling the typescript compiler that there is a global function
// called require. And to not freak out about references to it.
declare var require: any;
This also works for any other loader in the webpack universe
Reacted by Allen, Eric Simonton, Caner Candan, Jessica Voytek, Benoit A, Carlos, Diego Luiz Brum, Arthur Sharifullin and Doğancan Yiğit
So far I got it working with ng eject BUT this does not work with tests which again does desire an appropiate loader.
@Anthonyzou Your workaround does work for JIT but I don't seem to get it running with AOT.
The error reads as follows:
Error encountered resolving symbol values statically. Calling function 'template', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol abc in a/b/c
Following the advice of the error and some sites regarding aot I tried:
`
export function template() {
return require("pug-loader!./test.component.pug")();
}
@donmahallem I actually have no idea, actually. This is adapted from a graphql angular2 example where they manually require a graphql file and it works with AOT. It must also depend on how the loader is built.
Heya all, this isn't a feature that we're looking at adding in the 1.x timeframe, but rather something that would happen as a third party addon using the upcoming addon system for v2+.
Reacted by Jeremy Moritz
Reacted by Alonso Mendez, Doğancan Yiğit, Randall Meeker, Carlos, Jason Chaney, Ignat S., Vitaly Rudenko and Sergei Krivochenko
Going along with some of the recommendations above, I created a little script that can be ran to automatically insert the pug rule into the node_modules folder. @pexak
This can be used as a temporary solution until it can be available natively. Note this could need to be updated & changed if the CLI changes the location or formatting of this file. It's naively searching for rules: [ within this specific file.
npm i --D apply-loader pug-loader
pug-rule-insert.js
Now you can just create a simple js file with the code below (put it at your root project level).
@MarkPieszak@clovisj@chenzhiguang
[Warning] this trick works fine, as long as you do not name your template files something.TS.pug (which I used to do so they pop below their .ts counterpart in vscode)
If you do so, your AOT builds will fail silently (at least on my machine, as of today)
Activity
ShadowManu commentedon Sep 9, 2016
So you guys closed #996 and #968 in favor of #40, then closed #40 with no specific ending, then closed the efforts in #1433 and #626 because you changed to webpack and here we are with no answers.
Sorry, I'm not trying to be annoying, specially when I see a lot of hate on recent issues with bugs regarding latest TS/Angular/CLI combinations. I can understand error because we are humans, I can understand time because we need to sleep and have to live, but I do hate purposeful indifference, just because its not your problem. I'm open to work myself on the CLI on a new PR, but I do need guidance, and that really starts at least with a single answer in a timelapse of 10 days. Nevertheless, thank you for your efforts.
niklas-dahl commentedon Sep 12, 2016
This is my current "solution":
gulpfile.js:
.vscode/settings.json:
This actually works but it's obviously only a temporary solution..
ShadowManu commentedon Sep 12, 2016
My team is using
pug-cliwith--watchat the moment for the same results. However, I would prefer jade to be part of the webpack bundling itself. I'll submit a PR if I have time to figure out how to set it up.theklausster commentedon Sep 16, 2016
Any news on how to add pug to cli?
I opened a thread on Stockoverflow aswell, hoping for some result
http://stackoverflow.com/questions/39518500/how-to-add-pug-to-angular-cli
ShadowManu commentedon Sep 18, 2016
Opened a PR to see how this goes.
filipesilva commentedon Sep 21, 2016
Heya @ShadowManu, we're not trying to be indifferent and I'm sorry that the jade support has fallen to the wayside.
I can't say jade/pug support is a big on our radars right now to be honest. If you can get a PR to work I'm happy to review it, but bear in mind that it needs to have tests and documentation.
See https://github.com/angular/angular-cli#development-hints-for-hacking-on-angular-cli for a way to start working with a local copy of the CLI.
The command that runs the e2e suite is
node tests/e2e_runner.js. Have a look at https://github.com/angular/angular-cli/tree/master/tests/e2e/tests/build/styles for sass/less/styl tests.You should test that the the correct html is generated, and that base jade/pug functionality (like imports) works.
Regarding documentation, something akin to https://github.com/angular/angular-cli#css-preprocessor-integration should be enough.
Ideally we'd also support initializing a project with pug like we do with sass (
ng new sassy-project --style=sass), or setting the default template language (ng set defaults.styleExt scss) but to be honest that's further down the road.ShadowManu commentedon Sep 21, 2016
Thanks man. I'll be looking at the tests and a proper similar documentation as soon as I have time.
jurienhamaker commentedon Oct 10, 2016
Any updates @ShadowManu ?
nvrossett commentedon Oct 14, 2016
@ShadowManu please, you can look too the support to (lost-grid and/or jeet.gs) and rupture in stylus too?
ShadowManu commentedon Oct 15, 2016
@kingsdevelopment @filipesilva I've worked a little with some time I had on this, but got blocked on how to make the tests pass (specially on the time they take). I'll have a second try tomorrow.
@nvrossett not that I have knowledge of it. And probably should be on a different PR/issue.
qtleeq commentedon Nov 24, 2016
I just wanted to throw my support behind @tycho01 's pug-plugin-ng and pug-ng-html-loader. I used them to use pug with the Angular Class seed, and it really cleans up the syntax and makes development with Angular2 and pug very pleasant. I recommend checking it out:
https://github.com/tycho01/pug-plugin-ng
https://github.com/tycho01/pug-ng-html-loader
(pug-ng-html-loader is just a fork of pug-html-loader which allows pug-plugin-ng to work)
KiaraGrouwstra commentedon Nov 24, 2016
@TaylorDennisLee: thanks. note that for Webpack 2 it should work without the additional loader as well now, see the readme.
Edit: note that original pug syntax is not harmed/disabled; the plugin just patches the lexer to ensure this cleaner more natural (perspective: HTML) option is parsed correctly as well.
qtleeq commentedon Nov 24, 2016
@tycho01 Okay, so now pug-plugin-ng should work with pug-html-loader, as long as you are using Webpack 2?
Also, do you still have to do
template: require('./myComp.pug')
instead of:
templateUrl: 'myComp.pug'
Thanks,
Taylor
17 remaining items
ScallyGames commentedon Feb 24, 2017
@MarkPieszak this was my current solution to this problem.
Thanks for mentioning.
ausir0726 commentedon Mar 3, 2017
hope some day can support pug in angular-cli
Anthonyzou commentedon Mar 5, 2017
@mbonski
Your example is really close.
First install
pugandpug-loaderand use this example code.The only difference is
template: require('./app.component.pug')To =>
template: require('pug-loader!./app.component.pug')()You may also need to add the following into
typings.d.tsThis also works for any other loader in the webpack universe
donmahallem commentedon Mar 5, 2017
So far I got it working with ng eject BUT this does not work with tests which again does desire an appropiate loader.
@Anthonyzou Your workaround does work for JIT but I don't seem to get it running with AOT.
The error reads as follows:
Following the advice of the error and some sites regarding aot I tried:
`
export function template() {
return require("pug-loader!./test.component.pug")();
}
@component({
template: template()
})`
But it still errors with basicly the same message. Any ideas?
Anthonyzou commentedon Mar 5, 2017
@donmahallem I actually have no idea, actually. This is adapted from a graphql angular2 example where they manually require a graphql file and it works with AOT. It must also depend on how the loader is built.
filipesilva commentedon May 22, 2017
Heya all, this isn't a feature that we're looking at adding in the 1.x timeframe, but rather something that would happen as a third party addon using the upcoming addon system for v2+.
svallory commentedon Jul 28, 2017
Guys, I made a pull request to allow tweaking webpack config with a file in the project root. For now, you can use the cli at https://github.com/cashfarm/angular-advanced-cli (branch 1.2.x)
Install
pug,pug-ng-html-loaderand add awebpack.config.jswith this to root of your project:Then your components can use pug
But your index has to stay in html.
pexak commentedon Sep 20, 2017
Any update?
MarkPieszak commentedon Oct 1, 2017
Going along with some of the recommendations above, I created a little script that can be ran to automatically insert the pug rule into the node_modules folder. @pexak
This can be used as a temporary solution until it can be available natively. Note this could need to be updated & changed if the CLI changes the location or formatting of this file. It's naively searching for
rules: [within this specific file.pug-rule-insert.js
Now you can just create a simple js file with the code below (put it at your root project level).
Running it
Run it simply with:
node pug-rule-insert.jsor create a nicepostinstallhook to do it for you on new installs."postinstall": "node pug-rule-insert.js"Needed this for a client, hope this helps!
Works with
ng serve(even live reloads pug file changes) andAoTng prod builds, even Universal + CLI projects! 🎁clovisj commentedon Nov 3, 2017
Tnks @MarkPieszak
chenzhiguang commentedon Nov 29, 2017
@MarkPieszak thank you. I used pug-html-loader and html-loader instead, it is working fine, including the include ./pug-file
const pug_rule = `\n{ test: /.pug$/, loader: [ 'html-loader', { loader: "pug-html-loader", options: { doctype: 'html', pretty: true } } ], },`;
oguimbal commentedon Dec 16, 2017
@MarkPieszak @clovisj @chenzhiguang
[Warning] this trick works fine, as long as you do not name your template files something.TS.pug (which I used to do so they pop below their .ts counterpart in vscode)
If you do so, your AOT builds will fail silently (at least on my machine, as of today)
This one was f***ng hard to find. see #8904
angular-automatic-lock-bot commentedon Sep 7, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.