Created
March 3, 2013 13:26
-
-
Save hadashiA/5076082 to your computer and use it in GitHub Desktop.
サーバー/クライアント両方を javascript(coffee-script)で書くときのビルド設定 ref: http://qiita.com/items/808cdf082c74bfe6a0ce
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
. | |
├── Gruntfile.coffee | |
├── README.md | |
├── app.coffee | |
├── component.json | |
├── lib | |
├── package.json | |
├── public | |
│ ├── css | |
│ ├── img | |
│ └── js | |
├── src | |
│ ├── client | |
│ └── server | |
└── views |
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
module.exports = (grunt) -> | |
grunt.initConfig | |
pkg: grunt.file.readJSON('package.json') | |
coffee: | |
server: | |
files: [ | |
{ | |
'app.js': 'app.coffee' | |
}, { | |
expand: true, | |
cwd: 'src/server', | |
src: ['**/*.coffee'], | |
dest: 'lib/', | |
ext: '.js' | |
} | |
] | |
client: | |
options: | |
bare: false | |
files: [ | |
{ | |
expand: true, | |
cwd: 'src/client', | |
src: ['*.coffee'], | |
dest: 'public/js/lib/', | |
ext: '.js' | |
} | |
] | |
concat: | |
options: | |
separator: ";" | |
vendor: | |
src: [ | |
'components/underscore/underscore-min.js', | |
'components/jquery/jquery.min.js', | |
'components/backbone/backbone-min.js' | |
], | |
dest: "public/js/vendor.js" | |
app: | |
src: ["public/js/lib/**/*.js"] | |
dest: "public/js/app.js" | |
uglify: | |
options: | |
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n' | |
app: | |
files: | |
'public/js/app.min.js': ['<%= concat.app.dest %>'] | |
watch: | |
src_server: | |
files: ['app.coffee', 'src/server/**/*.coffee'] | |
tasks: ['coffee:server'] | |
src_client: | |
files: ['src/client/**/*.coffee'] | |
tasks: ['coffee:client', 'concat:app'] | |
grunt.loadNpmTasks('grunt-contrib-uglify') | |
grunt.loadNpmTasks('grunt-contrib-coffee') | |
grunt.loadNpmTasks('grunt-contrib-concat') | |
grunt.loadNpmTasks('grunt-contrib-watch') | |
grunt.registerTask 'default', ['coffee', 'concat', 'uglify'] | |
grunt.registerTask 'server', ['coffee:server'] | |
grunt.registerTask 'client', ['coffee:client', 'concat:app'] |
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
(defun grunt-for-build () | |
"coffee-script compile for grunt task" | |
(interactive) | |
(let ((cur-dir (expand-file-name default-directory))) | |
(compile | |
(if (string-match "/\\(server\\|client\\)s?/" cur-dir) | |
(concat "grunt " (match-string 1 cur-dir)) | |
"grunt")))) | |
(define-key coffee-mode-map (kbd "C-c C-l") #'grunt-for-build) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment