在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):waka/gulp-sprockets开源软件地址(OpenSource Url):https://github.com/waka/gulp-sprockets开源编程语言(OpenSource Language):JavaScript 94.1%开源软件介绍(OpenSource Introduction):gulp-sprocketsgulp-sprockets is a NodeJS implementation of Sprockets.
It is able to build and precompile assets of Rails apps solely with Node.js, without Rails. Provided gulp streams
Installation
Usagegulpfile.babel.js import gulp from 'gulp';
import gulpLoadPlugins from 'gulp-load-plugins';
import runSequence from 'run-sequence';
const $ = gulpLoadPlugins({ lazy: false });
const assetsPaths = {
app: "./app/assets",
javascripts: [],
stylesheets: [],
images: []
};
const destPath = "./public/assets";
const release = process.env.NODE_ENV === 'release'
// initialize sprockets!
$.sprockets.declare(assetsPaths, destPath);
/**
* Sprockets way
*/
gulp.task('build:image', () => {
return gulp.src([assetsPaths.app + '/images/**/*.png'])
.pipe($.if(release, $.sprockets.precompile()))
.pipe(gulp.dest(destPath))
});
gulp.task('build:js', () => {
return gulp.src([assetsPaths.app + '/javascripts/*.js'])
.pipe($.sprockets.js())
.pipe($.if(release, $.sprockets.precompile()))
.pipe(gulp.dest(destPath))
});
gulp.task('build:css', () => {
return gulp.src([assetsPaths.app + '/stylesheets/*.css'])
.pipe($.cached('css'))
.pipe($.sprockets.css({precompile: release}))
.pipe($.if(release, $.sprockets.precompile()))
.pipe(gulp.dest(destPath))
});
gulp.task('default', () => {
// the task of building image must be processed before others
runSequence('build:image', ['build:css', 'build:js']);
}) package.json
And then do build command.
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论