Last active
January 2, 2018 01:26
-
-
Save chrismccord/be5c3cf8f89b252122ba to your computer and use it in GitHub Desktop.
Phoenix Gulpfile.coffee (Sass/CoffeeScript)
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
# Gulpfile.js | |
# // Note the new way of requesting CoffeeScript since 1.7.x | |
# require('coffee-script/register'); | |
# // This bootstraps your Gulp's main file | |
# require('./Gulpfile.coffee'); | |
# assets | |
# ├── Gulpfile.coffee | |
# ├── Gulpfile.js | |
# ├── package.json | |
# ├── node_modules/ (auto generated) | |
# ├── cs/ | |
# └── sass/ | |
# | |
# Setup: | |
# $ cd my_app/assets | |
# $ npm install -g gulp | |
# $ npm install | |
# $ gulp watch | |
gulp = require 'gulp' | |
sass = require 'gulp-ruby-sass' | |
coffee = require 'gulp-coffee' | |
concat = require 'gulp-concat' | |
gulp.task 'watch', -> | |
gulp.watch 'sass/**/*.sass', ['css'] | |
gulp.watch 'cs/**/*.coffee', ['coffee'] | |
gulp.task 'css', -> | |
gulp.src 'sass/app.sass' | |
.pipe sass() | |
.pipe gulp.dest '../priv/static/css' | |
gulp.task 'coffee', -> | |
gulp.src 'cs/**/*.coffee' | |
.pipe coffee() | |
.pipe concat('app.js') | |
.pipe gulp.dest '../priv/static/js' | |
gulp.task 'default', ['css', 'coffee'] |
Or I got this error
Error: Cannot find module 'coffee-script/register'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/myers/p/sheep_phoenix/assets/Gulpfile.js:2:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
You may need to install coffee-script with npm's --save-dev
flag:
npm install --save-dev coffee-script
Now require("coffee-script/register");
should work in your gulpfile.js
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe because I don't have coffee-script install globally