Last active
August 26, 2015 05:14
-
-
Save coa00/8cd7cb9328f9fb3125a1 to your computer and use it in GitHub Desktop.
cssファイルをjavascriptにまとめる。 ref: http://qiita.com/coa00@github/items/8ea2c233afd9c1e50cfd
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
css/ | |
hoge.css | |
js/ | |
fuga.js | |
test.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
all.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
//cssをテンプレートに変換 | |
gulp.task('templates', function(){ | |
var src = "./src/css/"; | |
var dest = src+'/build';//出力場所 | |
gulp.src(src+'/*.css') | |
.pipe(handlebars()) | |
.pipe(wrap('Handlebars.template(<%= contents %>)')) | |
.pipe(declare({ | |
namespace: 'App.css', | |
noRedeclare: true // Avoid duplicate declarations | |
})) | |
.pipe(concat('style.js')) | |
.pipe(gulp.dest(dest)); | |
}); | |
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
gulp.task('concat', function() { | |
var dest = './dest';//結合したファイルの展開先 | |
var files = ['./src/css/build/style.js','./src/*.js'];//cssとjsを1ファイルに結合 | |
gulp.src(files) | |
.pipe(sourcemaps.init()) | |
.pipe(concat('all.js')) | |
.pipe(uglify()) //ついでに圧縮 | |
.pipe(gulp.dest(dest)); | |
}); | |
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
<body> | |
<script type="application/javascript"> | |
$("body").append(App.css.style); | |
</script> | |
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
var gulp = require('gulp'); | |
var uglify = require('gulp-uglify'); | |
var handlebars = require('gulp-handlebars'); | |
var wrap = require('gulp-wrap'); | |
var declare = require('gulp-declare'); |
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
<body> | |
<script type="application/javascript"> | |
$("body").append(App.css.style); | |
</script> | |
jsは以下にロードする。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment