Skip to content

Instantly share code, notes, and snippets.

@geckotang
Created October 2, 2014 12:35
Show Gist options
  • Select an option

  • Save geckotang/63ef8ba88264320fb66a to your computer and use it in GitHub Desktop.

Select an option

Save geckotang/63ef8ba88264320fb66a to your computer and use it in GitHub Desktop.
UTF-8のSCSSファイルからCSSを生成して、ファイルエンコーディングをShift_JISに変換する
module.exports = function(grunt){
var path = require('path');
var matchdep = require('matchdep');
matchdep.filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
compass: {
dev: {
options: {
bundleExec: true,
config: 'config.rb',
environment: 'development'
}
},
prod: {
options: {
bundleExec: true,
config: 'config.rb',
environment: 'production'
}
}
},
// watch some files status
watch: {
css: {
options: {
livereload: true
},
files: [
'scss/**/*.scss'
],
tasks: ['compass:dev', 'convertUTF8toSJIS']
}
},
replace: {
csstosjis: {
src: ['css/*.css'],
overwrite: true,
replacements: [{
from: /UTF-8/g,
to: "Shift_JIS"
}]
}
},
utf8tosjis: {
css: {
expand: true,
cwd : 'css/',
src : ['*.css'],
dest : 'css/',
ext : '.css'
}
}
});
// resiter tasks
grunt.registerTask('convertUTF8toSJIS', ['replace:csstosjis', 'utf8tosjis:css']);
grunt.registerTask('default', ['watch']);
};
{
"name": "SAMPLE",
"version": "1.0.0",
"description": "This is sample project",
"main": "",
"author": "@geckotang",
"readmeFilename": "README.md",
"devDependencies": {
"grunt": "~0.4.2",
"matchdep": "*",
"grunt-contrib-watch": "*",
"grunt-contrib-compass": "~0.5.0",
"grunt-utf8tosjis": "0.0.2",
"grunt-text-replace": "~0.3.12"
},
"dependencies": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment