README
Bundler
This is a node package that used to bundle assets (Javscript, Sass, etc.). The goal of this package is to provide an easy to use structure that automates the bundling of assets in an efficient way that is well suited for large scale enterprise applications.
Install
$ npm install --save-dev @chipchap/bundler
Usage
An example will be the @chipchap/bundler
can be used with default tasks.
Add following code to your gulpfile.babel.js
file.
import { Gulp, Tasks } from '@chipchap/bundler';
const _ = new Gulp(
new Tasks.Video({ dist: './test/dist/media', src: './test/src/media/**/*.{mp4,mov}' }),
new Tasks.Images({ dist: './test/dist/assets', src: ['./test/src/assets/**/icon.*.svg', './test/src/assets/**/*.{png,jpg,gif,ico}'] }),
new Tasks.Sprite({ dist: './test/dist/assets', src: './test/src/assets/**/!(icon.*).svg' }),
new Tasks.Sass({ dist: './test/dist', src: './test/src/sass/app.{scss,css}', watch: './test/src/sass/**/*.{scss,css}' }),
new Tasks.Javascript({ dist: './test/dist', eslint: ['./test/src/js/**/*.js'], entry: './test/src/js/App.js' }),
);
Create your own task
import { Utils, Task, Stream, Flow } from '@chipchap/bundler';
class MyTask extends Task {
constructor(props) {
super(props);
this.props = {
path: {
dist: {
myBundle: props.dist,
},
src: {
myBundle: props.src,
},
watch: props.watch || props.src,
},
plugins: {
imagemin: [[
Utils.$gulp.imagemin.gifsicle({ interlaced: true }),
]],
},
};
}
@Flow
myBundle() {
const stream = new Stream(this);
stream.pipe(Utils.$gulp.changed(this.path.dist.assets));
stream.pipe(Utils.$gulp.imagemin(...this.props.plugins.imagemin));
return stream.build();
}
}
const _ = new Gulp(
new MyTask({ dist: './test/dist/assets', src: './test/src/assets/**/*.gif' }),
);
License
The MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.