Skip to content

Instantly share code, notes, and snippets.

@nakajmg
Created January 27, 2014 19:52
Show Gist options
  • Save nakajmg/8655997 to your computer and use it in GitHub Desktop.
Save nakajmg/8655997 to your computer and use it in GitHub Desktop.
Grunt workflow
/* autoprefixer */
module.exports = {
options: {
browsers: ['ios >= 5', 'android >= 2.3']
},
dist: {
src: "./css/style.css"
}
};
/* config */
module.exports = {
connect: require("./connect"),
watch: require("./watch"),
sass: require("./sass"),
copy: require("./copy"),
csso: require("./csso"),
uglify: require("./uglify"),
autoprefixer: require("./autoprefixer")
};
/* connect */
module.exports = {
dist: {
options: {
port: 5000,
base: ".",
open: "http://localhost:5000"
}
}
};
/* csso */
module.exports = {
dist: {
files: {
"./css/style.min.css": ["./css/style.css"]
}
}
};
module.exports = function(grunt) {
var configObject, packageJson;
// 使いたいタスクが書いてあるconfigファイルを読み込む
configObject = require("./Gruntconfig/config");
// package.jsonを読み込む
packageJson = grunt.file.readJSON("package.json");
grunt.config.init(configObject);
// package.jsonに記述されたgruntタスクを読み込む
Object.keys(packageJson.devDependencies).slice(1).forEach(grunt.loadNpmTasks);
grunt.registerTask("default", ["connect", "watch"]);
grunt.registerTask("publish", ["sass", "autoprefixer", "csso"]);
};
{
"name": "GruntTemplate",
"version": "0.0.1",
"description": "my grunt template",
"main": "Gruntfile.coffee",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "nakajmg",
"license": "MIT",
"readmeFilename": "README.md",
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-sass": "~0.6.0",
"grunt-contrib-connect": "~0.5.0",
"grunt-csso": "~0.5.2",
"grunt-autoprefixer": "~0.6.4"
}
}
/* sass */
module.exports = {
dist: {
files: [
{
expand: true,
cwd: "./css/",
src: ["*.scss"],
dest: "./css/",
ext: ".css"
}
]
}
};
/* watch */
module.exports = {
sass: {
files: ["./css/*scss"],
tasks: ["sass", "autoprefixer"],
options: {
livereload: true
}
},
reload: {
files: ["./*.html", "./js/*.js"],
options: {
livereload: true
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment