Jade support in webpack releases
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?
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.
This is my current "solution":
gulpfile.js:
let path = require('path');
let gulp = require('gulp');
let pug = require('gulp-pug');
let pugFiles = './src/**/*.pug';
gulp.task('compilePug', () => {
gulp.src( pugFiles )
.pipe( pug().on('error', () => console.log('JADE ERROR')) )
.pipe( gulp.dest('./src') );
});
gulp.task('default', ['compilePug'], () => {
gulp.watch(pugFiles, ['compilePug']);
});
.vscode/settings.json:
{
"files.exclude": {
"src/app/**/*.html": {"when": "$(basename).pug"}
}
}
This actually works but it's obviously only a temporary solution..
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.
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
Opened a PR to see how this goes.
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.
Thanks man. I'll be looking at the tests and a proper similar documentation as soon as I have time.
Any updates @ShadowManu ?
@ShadowManu please, you can look too the support to (lost-grid and/or jeet.gs) and rupture in stylus too?
@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:
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)
@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.
@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
@TaylorDennisLee: yeah; if you're experiencing issues feel free to file them.
It does still need the require like that, though it seems angular-cli appeared to have addressed this for Sass and co., so I imagine they could for template engines like Pug as well.
@tycho01 can you please provide small guide how to add this loader to angular cli. I'm getting:
src/app/app.component.pug Unexpected token (1:3) You may need an appropriate loader to handle this file type.
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: require('./app.component.pug'),
styleUrls: ['app.component.scss']
})
export class AppComponent {
title = 'app works!';
}
@mbonski: I may have use for further info (where/how you set it, first line of the pug file, whether it worked without it). Could you post an issue with those here?
@tycho01 I created one. reference
I'd be interested to see how to do this with just temporary script that runs right before "ng serve" or "ng build" and also what in the angular-cli source code a change would naturally go. @tycho01 do you have a link for how they handled the Sass issue?
@TaylorDennisLee you might consider using a Gulp task for Pug compilation then, preferably along with one of the watchy kind. That's what I've been using, failing a better solution thus far. That could look something like this:
let gulp = require('gulp'),
gulpWatch = require('gulp-watch'),
runSequence = require('run-sequence'),
pug = require('gulp-pug'),
pug_plugin_ng = require('pug-plugin-ng');
let pug_opts = { doctype: 'html', plugins: [pug_plugin_ng], pretty: true };
let toSrc = gulp.dest((file) => file.base);
gulp.task('pug', () =>
gulp.src('src/**/*.pug')
.pipe(pug(pug_opts))
.pipe(toSrc)
);
gulp.task('watch', [], () => {
runSequence(
['pug'],
() => {
gulpWatch('src/**/*.pug', () => gulp.start('pug'));
}
);
});
As to changes, I linked ShadowManu's and mine in mbonski's issue thread.
On the Sass point, I didn't know yet :), but the magic appears to be located here. If I'm reading that correctly, than it should be automatically adding support for any extension already recognized by webpack. So I may have been wrong there earlier!
@TaylorDennisLee @tycho01 why not simply using pug src --watch & ng serve? Sure, since they're running simultaneously, webpack generally starts doing 2 builds. But hey, config-wise, you just need to install pug and pug-cli with npm.