11module . exports = function ( grunt ) {
22 const path = require ( 'path' ) ;
3- const babel = require ( 'rollup-plugin-babel' ) ;
4- const resolve = require ( 'rollup-plugin-node-resolve' ) ;
53 const sass = require ( 'node-sass' ) ;
64
75 require ( 'time-grunt' ) ( grunt ) ;
@@ -20,7 +18,6 @@ module.exports = function(grunt){
2018 const webDir = 'web/' ;
2119 const publicDir = webDir + 'public/' ;
2220 const nodeDir = 'node_modules/' ;
23- const docDir = 'doc/' ;
2421
2522 const banner = '/** MIT License\n' +
2623 '* \n' +
@@ -57,10 +54,6 @@ module.exports = function(grunt){
5754 compiledES6Dir + '*'
5855 ]
5956 } ,
60- doc :{
61- src : [ docDir + '*'
62- ]
63- } ,
6457 websass :{
6558 src : [ webDir + 'sass/build/*' ,
6659 publicDir + 'css/*'
@@ -75,16 +68,6 @@ module.exports = function(grunt){
7568 ]
7669 }
7770 } ,
78- typedoc : {
79- build : {
80- options : {
81- out : docDir ,
82- target : 'es6' ,
83- name : projectName + '.js - Documentation'
84- } ,
85- src : [ srcDir + 'ts/*.ts' ]
86- }
87- } ,
8871 // jshint: {
8972 // options: {
9073 // multistr: true
@@ -106,100 +89,6 @@ module.exports = function(grunt){
10689 } ]
10790 }
10891 } ,
109- csslint : {
110- dist : {
111- options : {
112- import : false
113- } ,
114- src : [ webDir + 'sass/build/**/*.css' ]
115- }
116- } ,
117- cssmin :{
118- options : {
119- shorthandCompacting : false ,
120- roundingPrecision : - 1
121- } ,
122- target : {
123- files : [
124- {
125- src : webDir + 'sass/build/grayscale.css' ,
126- dest : publicDir + 'css/style.min.css'
127- }
128- ]
129- }
130- } ,
131- htmlmin : {
132- static : {
133- options : {
134- removeComments : true ,
135- collapseWhitespace : true
136- } ,
137- expand : true ,
138- cwd : webDir + 'static' ,
139- src : [ '**/*.htm' ] ,
140- dest : webDir + 'static/'
141- }
142- } ,
143- ts : {
144- es6 : {
145- options : {
146- fast : 'never'
147- //rootDir: srcDir + 'ts/'
148- } ,
149- tsconfig : 'tsconfig.json' ,
150- src : [ srcDir + 'ts/**/*.ts' , '!node_modules/**/*.ts' ]
151- } ,
152- es6dev : {
153- options : {
154- // fast: 'always'
155- //rootDir: srcDir + 'ts/'
156- } ,
157- tsconfig : 'tsconfig-dev.json' ,
158- src : [ srcDir + 'ts/**/*.ts' , '!node_modules/**/*.ts' ]
159- } ,
160- } ,
161- rollup : {
162- es6 :{
163- options : {
164- format :'es' ,
165- // moduleName: projectName,
166- banner : banner ,
167- // sourceMap: 'inline'
168- plugins : [
169-
170- ] ,
171- external : [
172- '@lcluber/weejs' ,
173- '@lcluber/mouettejs' ,
174- '@lcluber/chjs'
175- ]
176- } ,
177- files : [ {
178- src : compiledES6Dir + projectNameLC + '.js' ,
179- dest : distDir + projectNameLC + '.js'
180- } ]
181- } ,
182- iife :{
183- options : {
184- format :'iife' ,
185- moduleName : projectName ,
186- banner : banner ,
187- plugins : [
188- babel ( {
189- // //exclude: './node_modules/**'
190- } ) ,
191- resolve ( {
192- // //exclude: './node_modules/**'
193- } )
194- ]
195- // sourceMap: 'inline'
196- } ,
197- files : [ {
198- src : compiledES6Dir + projectNameLC + '.js' ,
199- dest : distDir + projectNameLC + '.iife.js'
200- } ]
201- }
202- } ,
20392 uglify : {
20493 libIife : {
20594 options : {
@@ -325,6 +214,13 @@ module.exports = function(grunt){
325214 src : [ 'fonts/**/*' ] ,
326215 dest : publicDir ,
327216 filter : 'isFile'
217+ } ,
218+ css :{
219+ expand : true ,
220+ cwd : webDir + 'sass/build/' ,
221+ src : [ '*' ] ,
222+ dest : publicDir + 'css/' ,
223+ filter : 'isFile'
328224 }
329225 } ,
330226 nodemon : {
@@ -343,90 +239,38 @@ module.exports = function(grunt){
343239 path : 'http://' + host + ':' + port
344240 }
345241 } ,
346- watch : {
347- lib : {
348- files : [ srcDir + 'ts/**/*.ts' , '!' + srcDir + 'ts/build/**/*' ] ,
349- tasks : [ 'lib-dev' ]
350- } ,
351- webpug :{
352- files : webDir + 'views/**/*.pug'
353- } ,
354- webjs : {
355- files : webDir + 'js/**/*.js' ,
356- tasks : [ 'webjs' ]
357- } ,
358- websass : {
359- files : [ webDir + 'sass/**/*.scss' , '!' + webDir + 'sass/build/*' ] ,
360- tasks : [ 'websass' ]
361- } ,
362- options : {
363- interrupt : true ,
364- spawn : false ,
365- livereload : true ,
366- livereloadOnError :false
367- }
368- } ,
369242 // run watch and nodemon at the same time
370243 concurrent : {
371244 options : {
372245 logConcurrentOutput : true
373246 } ,
374- tasks : [ 'nodemon' , 'watch' , 'open' ]
247+ tasks : [ 'nodemon' ]
375248 }
376249 } ) ;
377250
378251 grunt . loadNpmTasks ( 'grunt-contrib-clean' ) ;
379252 grunt . loadNpmTasks ( 'grunt-contrib-copy' ) ;
380- grunt . loadNpmTasks ( 'grunt-contrib-jshint' ) ;
381253 grunt . loadNpmTasks ( 'grunt-contrib-uglify' ) ;
382- grunt . loadNpmTasks ( 'grunt-contrib-csslint' ) ;
383- grunt . loadNpmTasks ( 'grunt-contrib-cssmin' ) ;
384254 grunt . loadNpmTasks ( 'grunt-contrib-concat' ) ;
385- grunt . loadNpmTasks ( 'grunt-contrib-htmlmin' ) ;
386- grunt . loadNpmTasks ( 'grunt-contrib-watch' ) ;
387255 grunt . loadNpmTasks ( 'grunt-strip-code' ) ;
388256 grunt . loadNpmTasks ( 'grunt-concurrent' ) ;
389257 grunt . loadNpmTasks ( 'grunt-nodemon' ) ;
390- grunt . loadNpmTasks ( 'grunt-open' ) ;
391- grunt . loadNpmTasks ( 'grunt-ts' ) ;
392- grunt . loadNpmTasks ( 'grunt-rollup' ) ;
393- grunt . loadNpmTasks ( 'grunt-typedoc' ) ;
394258 grunt . loadNpmTasks ( 'grunt-sass' ) ;
395259
396260
397- grunt . registerTask ( 'lib ' ,
261+ grunt . registerTask ( 'ugly ' ,
398262 'build the library in the dist/ folder' ,
399- [ // 'tslint:lib',
400- 'clean:lib' ,
401- //lib es6
402- 'ts:es6' ,
403- 'rollup:es6' ,
404- //lib es5
405- //'ts:es5',
406- 'rollup:iife' ,
407- 'uglify:libIife' ,
408- //declaration
409- 'concat:declaration' ,
410- 'strip_code:declaration'
263+ [ 'uglify:libIife'
411264 ]
412265 ) ;
413266
414- grunt . registerTask ( 'lib-dev ' ,
267+ grunt . registerTask ( 'declaration ' ,
415268 'build the library in the dist/ folder' ,
416- [ 'ts:es6dev' ,
417- 'rollup:es6' ,
418- 'rollup:iife' ,
419- 'uglify:libIife'
269+ [ 'concat:declaration' ,
270+ 'strip_code:declaration'
420271 ]
421272 ) ;
422273
423- grunt . registerTask ( 'doc' ,
424- 'Compile lib documentation' ,
425- [ 'clean:doc' ,
426- 'typedoc'
427- ]
428- ) ;
429-
430274 grunt . registerTask ( 'serve' ,
431275 'launch server, open website and watch for changes' ,
432276 [ 'concurrent' ]
@@ -436,7 +280,8 @@ module.exports = function(grunt){
436280 'Compile website css' ,
437281 [ 'clean:websass' ,
438282 'sass' ,
439- 'cssmin' ,
283+ // 'cssmin',
284+ 'copy:css' ,
440285 'concat:webcss'
441286 ]
442287 ) ;
@@ -466,40 +311,4 @@ module.exports = function(grunt){
466311 }
467312 ) ;
468313
469- grunt . registerTask ( 'buildprod' ,
470- 'build for production' ,
471- function ( ) {
472- //build lib
473- grunt . task . run ( 'lib' ) ;
474- //build site
475- grunt . task . run ( 'website' ) ;
476- //build documentation
477- grunt . task . run ( 'doc' ) ;
478- // launch server and watch for changes
479- grunt . task . run ( 'serve' ) ;
480- }
481- ) ;
482-
483- grunt . registerTask ( 'build' ,
484- 'build for developpment' ,
485- function ( ) {
486- //build lib
487- grunt . task . run ( 'lib-dev' ) ;
488- //build site
489- grunt . task . run ( 'website' ) ;
490- //build documentation
491- //grunt.task.run('doc');
492- // launch server and watch for changes
493- grunt . task . run ( 'serve' ) ;
494- }
495- ) ;
496-
497- grunt . registerTask ( 'default' ,
498- 'build library, website, launch server, open website and watch for changes.' ,
499- function ( ) {
500- // launch server and watch for changes
501- grunt . task . run ( 'serve' ) ;
502- }
503- ) ;
504-
505314} ;
0 commit comments