Last active
January 4, 2018 15:25
-
-
Save mitchellmorris/b5813cf622441caa5927 to your computer and use it in GitHub Desktop.
This is a custom grunt configuration merged in with generator-angular-fullstack that I have started to use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //add this after grunt.registerTask('serve', function (target) { ... } | |
| grunt.config.merge({ | |
| // Compiles CoffeeScript to JavaScript | |
| coffee: { | |
| modules: { | |
| options: { | |
| sourceMap: false | |
| }, | |
| files: [{ | |
| expand: true, | |
| cwd: 'server/modules', | |
| src: [ | |
| '**/*.coffee' | |
| ], | |
| dest: 'server', | |
| ext: '.js', | |
| extDot: 'last' | |
| }] | |
| }, | |
| server: { | |
| files: [{ | |
| expand: true, | |
| cwd: 'client', | |
| src: [ | |
| '{app,components}/**/*.coffee', | |
| '!{app,components}/**/*.spec.coffee', | |
| '!{app,components}/**/*.shared.coffee', | |
| '!{app,components}/**/*.dependency.coffee', | |
| '!{app,components}/**/*.dev.coffee' | |
| ], | |
| dest: '.tmp', | |
| ext: '.js' | |
| }, { | |
| expand: true, | |
| cwd: 'client', | |
| src: [ | |
| '{app,components}/**/*.shared.coffee' | |
| ], | |
| dest: '.tmp', | |
| ext: '.shared.js' | |
| }, { | |
| expand: true, | |
| cwd: 'client', | |
| src: [ | |
| '{app,components}/**/*.dev.coffee' | |
| ], | |
| dest: '.tmp', | |
| ext: '.dev.js' | |
| }, { | |
| expand: true, | |
| cwd: 'client', | |
| src: [ | |
| '{app,components}/**/*.dependency.coffee' | |
| ], | |
| dest: '.tmp', | |
| ext: '.dependency.js' | |
| }] | |
| } | |
| }, | |
| less: { | |
| options: { | |
| paths: [ | |
| '<%= yeoman.client %>/bower_components', | |
| '<%= yeoman.client %>/app', | |
| '<%= yeoman.client %>/components', | |
| '<%= yeoman.client %>/assets/styles' | |
| ] | |
| } | |
| }, | |
| // Test settings | |
| karma: { | |
| unit: { | |
| browsers: ['Chrome'] | |
| } | |
| }, | |
| grunticon: { | |
| options: { | |
| cssprefix:".tq-icon-" | |
| }, | |
| icons: { | |
| files: [{ | |
| expand: true, | |
| cwd: '<%= yeoman.client %>/assets/images/src', | |
| src: ['*.svg', '*.png'], | |
| dest: '<%= yeoman.client %>/assets/styles/grunticon' | |
| }] | |
| } | |
| }, | |
| webfont: { | |
| icons: { | |
| src: '<%= yeoman.client %>/assets/images/src/*.svg', | |
| dest: '<%= yeoman.client %>/assets/fonts', | |
| destCss: '<%= yeoman.client %>/assets/styles/webfont', | |
| options: { | |
| stylesheet: 'less', | |
| relativeFontPath: '/assets/fonts/', | |
| templateOptions: { | |
| baseClass: 'tq-glyphicon', | |
| classPrefix: 'tq-glyphicon-', | |
| mixinPrefix: 'tqGlyphicon-' | |
| } | |
| } | |
| } | |
| }, | |
| rev: { | |
| dist: { | |
| files: { | |
| src: [ | |
| '<%= yeoman.dist %>/public/{,*/}*.js', | |
| '<%= yeoman.dist %>/public/{,*/}*.css', | |
| '<%= yeoman.dist %>/public/assets/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}', | |
| '<%= yeoman.dist %>/public/assets/fonts/*', | |
| '!<%= yeoman.dist %>/public/assets/fonts/icons.*' | |
| ] | |
| } | |
| } | |
| }, | |
| // Automatically inject Bower components into the app | |
| wiredep: { | |
| target: { | |
| exclude: [ | |
| /bootstrap-sass-official/, | |
| /bootstrap.js/, | |
| '/json3/', | |
| '/es5-shim/', | |
| /bootstrap.css/, | |
| /font-awesome.css/, | |
| /bootstrap-3-timepicker\/css/, | |
| /seiyria-bootstrap-slider\/dist\/css/, | |
| /clockpicker\/dist\/.*\.css/, | |
| /common\/.*\.css/ | |
| ] | |
| } | |
| }, | |
| injector: { | |
| // Inject application script files into index.html (doesn't include bower) | |
| scripts: { | |
| files: { | |
| '<%= yeoman.client %>/index.html': [ | |
| ['{.tmp,<%= yeoman.client %>}/{app,components}/**/*.js', | |
| '!{.tmp,<%= yeoman.client %>}/app/app.js', | |
| '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.dev.js', | |
| '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.shared.js', | |
| '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.dependency.js', | |
| '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.spec.js', | |
| '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.mock.js'] | |
| ] | |
| } | |
| }, | |
| shared: { | |
| options: { | |
| transform: function(filePath) { | |
| filePath = filePath.replace('/client/', ''); | |
| filePath = filePath.replace('/.tmp/', ''); | |
| return '<script src="' + filePath + '"></script>'; | |
| }, | |
| starttag: '<!-- shared:js -->', | |
| endtag: '<!-- endshared -->' | |
| }, | |
| files: { | |
| '<%= yeoman.client %>/index.html': [ | |
| '{.tmp,<%= yeoman.client %>}/{app,components}/**/*.shared.js' | |
| ] | |
| } | |
| }, | |
| dependency: { | |
| options: { | |
| transform: function(filePath) { | |
| filePath = filePath.replace('/client/', ''); | |
| filePath = filePath.replace('/.tmp/', ''); | |
| return '<script src="' + filePath + '"></script>'; | |
| }, | |
| starttag: '<!-- dependencies:js -->', | |
| endtag: '<!-- enddependencies -->' | |
| }, | |
| files: { | |
| '<%= yeoman.client %>/index.html': [ | |
| '{.tmp,<%= yeoman.client %>}/{app,components}/**/*.dependency.js' | |
| ] | |
| } | |
| }, | |
| dev: { | |
| options: { | |
| transform: function(filePath) { | |
| filePath = filePath.replace('/client/', ''); | |
| filePath = filePath.replace('/.tmp/', ''); | |
| return '<script src="' + filePath + '"></script>'; | |
| }, | |
| starttag: '<!-- dev:js -->', | |
| endtag: '<!-- enddev -->' | |
| }, | |
| files: { | |
| '<%= yeoman.client %>/index.html': [ | |
| '{.tmp,<%= yeoman.client %>}/{app,components}/**/*.dev.js' | |
| ] | |
| } | |
| } | |
| }, | |
| watch: { | |
| modules: { | |
| files: [ | |
| 'server/modules/**/*.{coffee,litcoffee,coffee.md}', | |
| '!server/modules/**/*.spec.{coffee,litcoffee,coffee.md}' | |
| ], | |
| tasks: ['coffee:modules'] | |
| }, | |
| coffee: { | |
| tasks: ['newer:coffee', 'injector:scripts', 'injector:shared', 'injector:dev', 'injector:dependency'] | |
| }, | |
| less: { | |
| files: [ | |
| '<%= yeoman.client %>/{app,components,assets/styles}/**/*.less' | |
| ] | |
| }, | |
| livereload: { | |
| files: [ | |
| '{.tmp,<%= yeoman.client %>}/{app,components}/**/*.css', | |
| '{.tmp,<%= yeoman.client %>}/{app,components}/**/*.html', | |
| '{.tmp,<%= yeoman.client %>}/{app,components}/**/*.js', | |
| '!{.tmp,<%= yeoman.client %>}{app,components}/**/*.spec.js', | |
| '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.mock.js', | |
| '<%= yeoman.client %>/assets/images/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}', | |
| '{.tmp,<%= yeoman.client %>}/bower_components/common/**/*.less' | |
| ], | |
| options: { | |
| livereload: true | |
| } | |
| } | |
| } | |
| }); | |
| grunt.registerTask('j2c', 'JS to Coffee', function(jSPath, cPath) { | |
| grunt.log.writeln(jSPath + '/**/*.js to ' + cPath + '**/*.coffee'); | |
| var j2c = { | |
| js2coffee: { | |
| modules: { | |
| files: [{ | |
| expand: true, | |
| cwd: jSPath, | |
| src: [ | |
| '**/*.js', | |
| '!**/*.spec.js', | |
| '!**/index.js' | |
| ], | |
| dest: cPath, | |
| ext: '.coffee', | |
| extDot: 'last' | |
| }] | |
| } | |
| } | |
| }; | |
| grunt.config.merge(j2c); | |
| grunt.log.writeln('Starting conversion to coffee.'); | |
| grunt.task.run('js2coffee'); | |
| }); | |
| grunt.registerTask('api', 'Convenience task for translating new api service to coffeescript.', function(service) { | |
| grunt.task.run("j2c:server/api/" + service + ":server/modules/api/" + service + "/"); | |
| }); | |
| grunt.registerTask('generateDevPartials', 'Creates head.html and close.html partials to be used with server views.', function() { | |
| var index = grunt.file.read('./client/index.html'); | |
| var head = index.substr(0, index.indexOf('<!-- Add your site or application content here -->')); | |
| grunt.file.write('./server/views/partials/page/head.html', head); | |
| var close = index.substr(index.indexOf('<div ui-view=""></div>') + '<div ui-view=""></div>'.length, index.length); | |
| grunt.file.write('./server/views/partials/page/close.html', close); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment