Last active
January 1, 2016 05:19
-
-
Save mitsuruog/8098078 to your computer and use it in GitHub Desktop.
Yeomanに学ぶモテるGruntfile.jsの書き方
This file contains 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
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
uglify: { | |
options: { | |
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' | |
}, | |
dist: { | |
src: 'src/<%= pkg.name %>.js', | |
dest: 'dist/<%= pkg.name %>.min.js' | |
} | |
} | |
}); |
This file contains 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
/** | |
* before | |
*/ | |
grunt.loadNpmTasks('grunt-shell'); | |
grunt.loadNpmTasks('grunt-sass'); | |
grunt.loadNpmTasks('grunt-recess'); | |
grunt.loadNpmTasks('grunt-sizediff'); | |
grunt.loadNpmTasks('grunt-svgmin'); | |
grunt.loadNpmTasks('grunt-styl'); | |
grunt.loadNpmTasks('grunt-php'); | |
grunt.loadNpmTasks('grunt-eslint'); | |
grunt.loadNpmTasks('grunt-concurrent'); | |
grunt.loadNpmTasks('grunt-bower-requirejs'); | |
/** | |
* after | |
*/ | |
require('load-grunt-tasks')(grunt); |
This file contains 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
// 普通はこんな感じ | |
grunt.registerTask('serve', [ | |
'clean:server', | |
'concurrent:server', | |
'autoprefixer', | |
'connect:livereload', | |
'watch' | |
]); | |
// grunt serve:distと呼ぶことタスクの中で分岐ができる | |
grunt.registerTask('serve', function (target) { | |
if (target === 'dist') { | |
return grunt.task.run(['build', 'connect:dist:keepalive']); | |
} | |
grunt.task.run([ | |
'clean:server', | |
'concurrent:server', | |
'autoprefixer', | |
'connect:livereload', | |
'watch' | |
]); | |
}); |
This file contains 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
grunt.initConfig({ | |
yeoman: { | |
// Configurable paths | |
app: 'app', | |
dist: 'dist' | |
}, | |
copy: { | |
dist: { | |
files: [{ | |
expand: true, | |
dot: true, | |
cwd: '<%= yeoman.app %>', // <- ここ | |
dest: '<%= yeoman.dist %>', // <- ここ | |
src: [ | |
'*.{ico,png,txt}' | |
] | |
}] | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment