ludohenin / gulp-inline-ng2-styles Goto Github PK
View Code? Open in Web Editor NEWGulp plugin to inline style sheets into Angular 2 component views
License: MIT License
Gulp plugin to inline style sheets into Angular 2 component views
License: MIT License
The following is the header of my NG2 class
import {Component} from '@angular/core';
import { ApplicationConstants } from '../../constants/ApplicationConstants';
import { Hero } from './hero'
import { HeroDetailComponent } from './detail/hero-detail.component';
import { HeroService } from './hero.service';
import { OnInit } from '@angular/core';
import {MdIconRegistry} from "@angular2-material/icon/icon-registry";
import {MD_CARD_DIRECTIVES} from "@angular2-material/card/card";
import {MD_BUTTON_DIRECTIVES} from "@angular2-material/button/button";
import {MD_ICON_DIRECTIVES} from "@angular2-material/icon/icon";
import {MD_LIST_DIRECTIVES} from "@angular2-material/list/list";
import {MD_INPUT_DIRECTIVES} from "@angular2-material/input/input";
import {MdToolbar} from "@angular2-material/toolbar/toolbar";
@Component({
selector: 'hero',
templateUrl: 'hero.component.html',
styleUrls: [ 'components/hero/hero.component.css' ],
directives: [HeroDetailComponent, MD_CARD_DIRECTIVES, MD_BUTTON_DIRECTIVES, MD_LIST_DIRECTIVES, MD_ICON_DIRECTIVES, MdToolbar, MD_INPUT_DIRECTIVES],
providers: [HeroService],
viewProviders: [MdIconRegistry]
})
then the plugin is configured....
gulp.task('js:build', function () {
var tsProject = ts.createProject('tsconfig.json');
return tsProject.src() // also can use *.js files
.pipe(embedTemplates({sourceType: 'ts'}))
.pipe(inlineNg2Styles({base: '/src/ng2'}))
.pipe(sourcemaps.init())
.pipe(ts(tsProject))
.pipe(sourcemaps.write())
.pipe(gulp.dest("public/ng2"));
});
When I try to run the inline styling I get...
ReferenceError: HeroDetailComponent is not defined
at eval (eval at replace (C:\Users\jgleason\dev\code\ng2-demo-app\node_modules\gulp-inline-ng2-styles\index.js:86:36), :25:18)
at replace (C:\Users\jgleason\dev\code\ng2-demo-app\node_modules\gulp-inline-ng2-styles\index.js:86:14)
at C:\Users\jgleason\dev\code\ng2-demo-app\node_modules\gulp-inline-ng2-styles\index.js:74:44
The project I am trying to integrate with is https://github.com/jrgleason/ng2-demo-app
This is buggy
@View({
templateUrl: './app.html',
styleUrls: ['./app.css'],
directives: [ROUTER_DIRECTIVES]
})
where this works
@View({
templateUrl: './app.html?v=<%= VERSION %>',
styleUrls: [
'./app.css'
],
directives: [ROUTER_DIRECTIVES]
})
I'm trying to use this package to inline my scss
files into angular2 components.
My gulpfile:
gulp.task('js:build', function () {
gulp.src('src/**/*.ts')
.pipe(embedTemplates({ sourceType: 'ts'}))
.pipe(inlineNg2Styles({ base: '/dist/styles', extension: '.scss' }))
.pipe(gulp.dest('./dist'));
});
But when running I get a SyntaxError: Unexpected token export
exception.
stack trace:
SyntaxError: Unexpected token export
at replace (...\node_modules\gulp-inline-ng2-styles\index.js:88:36)
at ...\node_modules\gulp-inline-ng2-styles\index.js:74:44
at Array.forEach (native)
at inline (...\node_modules\gulp-inline-ng2-styles\index.js:50:9)
at DestroyableTransform._transform (...\node_modules\gulp-inline-ng2-styles\index.js:30:34)
at DestroyableTransform.Transform._read (...\node_modules\gulp-inline-ng2-styles\node_modules\readable-stream\lib\_stream_transform.js:159:10)
at DestroyableTransform.Transform._write (...\node_modules\gulp-inline-ng2-styles\node_modules\readable-stream\lib\_stream_transform.js:147:83)
at doWrite (...\node_modules\gulp-inline-ng2-styles\node_modules\readable-stream\lib\_stream_writable.js:347:64)
at writeOrBuffer (...\node_modules\gulp-inline-ng2-styles\node_modules\readable-stream\lib\_stream_writable.js:336:5)
at DestroyableTransform.Writable.write (...\node_modules\gulp-inline-ng2-styles\node_modules\readable-stream\lib\_stream_writable.js:274:11)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.