1+ var gulp = require ( 'gulp' ) ;
2+ var path = require ( 'path' ) ;
3+ var runSequence = require ( 'run-sequence' ) ;
4+ var autoLoadAureliaLoaders = function ( ) {
5+ var loader = function ( ) { }
6+ loader . prototype . init = function ( context ) { }
7+ loader . prototype . bundleEnd = function ( context ) {
8+ context . source . addContent ( `FuseBox.import("fuse-box-aurelia-loader")` ) ;
9+ context . source . addContent ( `FuseBox.import("aurelia-bootstrapper")` ) ;
10+ }
11+ return new loader ( ) ;
12+ }
13+
14+ // so fusebox uses correct path
15+ process . env . PROJECT_ROOT = path . resolve ( process . cwd ( ) , './sample/' )
16+
117// builtin plugins
218const {
319 RawPlugin,
420 FuseBox,
521 HTMLPlugin,
622 CSSPlugin,
723 Sparky
8- } = require ( "fuse-box" ) ;
24+ } = require ( "../sample/node_modules/ fuse-box" ) ;
925
26+ var TypeHelper = require ( '../sample/node_modules/fuse-box-typechecker' ) . TypeHelper
1027
1128
29+ gulp . task ( 'copy-fonts' , ( ) => {
30+ return gulp . src ( 'node_modules/materialize-css/dist/fonts/**/**.**' )
31+ . pipe ( gulp . dest ( 'fonts/' ) ) ;
32+ } ) ;
1233
1334
14- Sparky . task ( 'copy-fonts' , ( ) => {
15- Sparky . src ( 'node_modules/materialize-css/dist/fonts/**/**.**' )
16- . dest ( 'fonts/' ) ;
35+ // sample typechecker
36+ gulp . task ( 'sample-typechecker' , function ( ) {
37+ // set correct dir first..
38+ process . chdir ( './sample' ) ;
39+ var testWatch = TypeHelper ( {
40+ tsConfig : './tsconfig.json' ,
41+ name : 'Sample Watch'
42+ } )
43+ testWatch . runWatch ( './src' )
44+ return true ;
1745} ) ;
1846
1947
48+ gulp . task ( 'plugin-typechecker' , function ( ) {
49+ // set correct dir first..
50+
51+ var testWatch = TypeHelper ( {
52+ tsConfig : './tsconfig.json' ,
53+ name : 'Plugin Watch'
54+ } )
55+ testWatch . runWatch ( './src' )
56+ return true ;
57+ } ) ;
58+
2059
2160
61+ // this task will start fusebox
62+ gulp . task ( 'fuse-sample' , function ( ) {
2263
23- Sparky . task ( 'dev' , ( ) => {
24- // typechecker (minor bug first time when caching vendor bundle, its on my todo list(vegar)... just need to talk to fusebox team..)
25- const TypeCheckPlugin = require ( 'fuse-box-typechecker' ) . TypeCheckPlugin ;
64+ // init fusebox
2665 const fuse = FuseBox . init ( {
2766 homeDir : './src' ,
2867 output : './dist/$name.js' ,
2968 plugins : [
30- TypeCheckPlugin ( ) ,
69+ autoLoadAureliaLoaders ( ) ,
3170 CSSPlugin ( ) ,
3271 HTMLPlugin ( ) ,
33- RawPlugin ( [ '.css' , '.woff' ] )
72+ RawPlugin ( [ '.css' ] )
3473 ]
3574 } ) ;
3675
76+
3777 fuse . register ( 'materialize-css-styles' , {
3878 homeDir : 'node_modules/materialize-css/dist/css' ,
3979 main : 'materialize.css' ,
@@ -48,7 +88,7 @@ Sparky.task('dev', () => {
4888 instructions : '**/*.{html,css,js}'
4989 } ) ;
5090
51-
91+ // vendor bundle
5292 fuse . bundle ( "vendor" )
5393 . cache ( true )
5494 . instructions ( `
@@ -61,15 +101,16 @@ Sparky.task('dev', () => {
61101 + aurelia-fetch-client
62102 + aurelia-pal-browser
63103 + aurelia-animator-css
104+ + fuse-box-css
64105 + aurelia-logging-console
65106 + aurelia-templating-binding
66107 + aurelia-templating-resources
67108 + aurelia-event-aggregator
68109 + aurelia-history-browser
69110 + aurelia-templating-router
70111 + aurelia-materialize-bridge
71- + materialize-css-styles` )
72- . alias ( {
112+ + materialize-css-styles
113+ ` ) . alias ( {
73114 'jQuery' : 'jquery'
74115 } )
75116 . shim ( {
@@ -93,54 +134,47 @@ Sparky.task('dev', () => {
93134 + [**/*.{ts,html,css}]
94135 ` ) ;
95136
96-
97-
137+ // web server
98138 fuse . dev ( {
99139 root : './'
100140 } ) ;
101- fuse . run ( ) ;
102- } ) ;
103-
104141
142+ // run
143+ return fuse . run ( )
144+ } ) ;
105145
106146
147+ // this task will start fusebox
148+ gulp . task ( 'fuse-plugin' , function ( ) {
107149
108- Sparky . task ( 'loader' , ( ) => {
109- // typechecker (minor bug first time when caching vendor bundle, its on my todo list(vegar)... just need to talk to fusebox team..)
110- const TypeCheckPlugin = require ( 'fuse-box-typechecker' ) . TypeCheckPlugin ;
150+ // package init
111151 const fuse = FuseBox . init ( {
112152 homeDir : '../src' ,
113153 output : './dist/$name.js' ,
114- plugins : [
115- TypeCheckPlugin ( ) ,
116- CSSPlugin ( ) ,
117- HTMLPlugin ( ) ,
118- RawPlugin ( [ '.css' , '.woff' ] )
119- ] ,
154+ plugins : [ ] ,
120155 package : {
121156 name : "fuse-box-aurelia-loader" ,
122157 main : "fuse-box-aurelia-loader.ts"
123158 } ,
124159 } ) ;
125160
126161
127- // app bundle
128- // todo, we need to have vendor bundle and app bundle...
162+ // plugin bundle
129163 fuse . bundle ( 'fuse-box-aurelia-loader' )
130164 . watch ( ) . cache ( false )
131165 . instructions ( `
132166 [*.ts]
133-
134167 ` ) . sourceMaps ( true ) ;
135168
136169
137-
138-
139- fuse . run ( ) ;
170+ //build file
171+ return fuse . run ( ) ;
140172} ) ;
141173
142174
143- // run dev and loader build in parallell
144- Sparky . task ( "run" , [ "&loader" , "&dev" ] , ( ) => {
145-
175+ // this task will start fusebox
176+ gulp . task ( 'watch' , function ( ) {
177+ return runSequence (
178+ 'fuse-plugin' , 'fuse-sample' , 'plugin-typechecker' , 'sample-typechecker' , 'copy-fonts'
179+ ) ;
146180} ) ;
0 commit comments