Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var rollup = require('rollup');
- var uglify = require('rollup-plugin-uglify');
- var eslint = require('rollup-plugin-eslint');
- function rollupTask(entry, dest) {
- var plugins = [
- eslint({
- exclude: [
- 'src/static/styles/**',
- 'src/static/libs/**',
- 'src/static/scripts/libs/**'
- ]
- })
- ];
- if (argv.prod) {
- plugins.push(uglify());
- }
- return rollup.rollup({
- entry: entry,
- plugins: plugins
- })
- .then(function(bundle) {
- bundle.write({
- format: 'iife',
- moduleName: 'main',
- dest: dest
- });
- });
- }
- gulp.task('scripts', function(end) {
- fs.readdir(entry_script, function(err, items) {
- if (err) {
- end();
- }
- var i = 0;
- var l = items.length;
- var file = '';
- var name = '';
- for (; i<l; ++i) {
- name = items[i];
- file = path.join(entry_script, items[i]);
- if (test_script.test(file)) {
- rollupTask(file, path.join(dest_script, name));
- }
- }
- end();
- });
- });
- watch.onChanged = function(event) {
- if (event.type == 'changed' && test_script.test(event.path)) {
- rollupTask(event.path, event.path.replace(entry_script, dest_script));
- }
- };
Add Comment
Please, Sign In to add comment