Skip to content

Commit

Permalink
build(rollup): replace babel with buble
Browse files Browse the repository at this point in the history
  • Loading branch information
ritz078 committed Feb 24, 2017
1 parent b64ed1a commit 9e8f4c5
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 100 deletions.
100 changes: 48 additions & 52 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,27 @@ module.exports = function (grunt) {
options: {
livereload: true
},
css : {
css: {
files: ['src/css/**/*.scss'],
tasks: ['sass', 'postcss']
},
js : {
js: {
files: ['src/js/**/*.js', 'build.json'],
tasks: ['eslint', 'shell:rollup', 'uglify']
}
},

postcss: {
options: {
map : false,
map: false,
processors: [
require('cssnano')({
convertValues: false
})
]
},
dist : {
src : 'dist/embed.css',
dist: {
src: 'dist/embed.css',
dest: 'dist/embed.min.css'
}
},
Expand All @@ -53,13 +53,13 @@ module.exports = function (grunt) {

'sprite': {
all: {
src : './assets/images/ejs_emojis/*.png',
dest : './assets/images/emojis.png',
retinaSrcFilter : './assets/images/ejs_emojis/*@2x.png',
destCss : 'src/css/_emojis.scss',
retinaDest : './assets/images/[email protected]',
cssFormat : 'css',
cssTemplate : 'sprite.handlebars',
src: './assets/images/ejs_emojis/*.png',
dest: './assets/images/emojis.png',
retinaSrcFilter: './assets/images/ejs_emojis/*@2x.png',
destCss: 'src/css/_emojis.scss',
retinaDest: './assets/images/[email protected]',
cssFormat: 'css',
cssTemplate: 'sprite.handlebars',
cssHandlebarsHelpers: {
escape: function (name) {
var x = ['+', '-', '/', '*'];
Expand All @@ -81,11 +81,11 @@ module.exports = function (grunt) {
}
}
},
files : {
files: {
expand: true,
cwd : 'assets/images/emojis',
src : ['*.png'],
dest : 'assets/images/ejs_emojis/'
cwd: 'assets/images/emojis',
src: ['*.png'],
dest: 'assets/images/ejs_emojis/'
}
},

Expand All @@ -94,69 +94,65 @@ module.exports = function (grunt) {
options: {
style: 'expanded'
},
files : {
files: {
'dist/embed.css': 'src/css/embed.scss'
}
}
},

'uglify': {
options: {
banner : "<%= meta.banner %>",
mangle : true,
banner: "<%= meta.banner %>",
mangle: true,
compress: {
sequences : true,
dead_code : true,
sequences: true,
dead_code: true,
conditionals: true,
booleans : true,
unused : true,
if_return : true,
join_vars : true,
booleans: true,
unused: true,
if_return: true,
join_vars: true,
drop_console: true
}
},
build : {
build: {
files: {
'dist/embed.min.js': 'dist/embed.js'
}
}
},
connect : {
connect: {
server: {
options: {
port : 8000,
port: 8000,
livereload: true,
open : true,
keepAlive : true,
base : {
path : './',
open: true,
keepAlive: true,
base: {
path: './',
options: {
index : 'demo/index.html',
index: 'demo/index.html',
maxAge: 300000
}
}
}
}
},

eslint: {
target: ['src/js/**/*.js']
},

'string-replace': {
dist: {
files : {
files: {
'.tmp/embed.css': 'dist/embed.css'
},
options: {
replacements: [{
pattern : /..\/assets\/images\/loader.svg/g,
pattern: /..\/assets\/images\/loader.svg/g,
replacement: 'assets/images'
}, {
pattern : /..\/.\/assets\/images\/emojis/g,
pattern: /..\/.\/assets\/images\/emojis/g,
replacement: 'assets/images/emojis'
}, {
pattern : /..\/assets\/fonts/g,
pattern: /..\/assets\/fonts/g,
replacement: 'assets/fonts'
}]
}
Expand All @@ -167,22 +163,22 @@ module.exports = function (grunt) {
dist: {
files: [{
expand: true,
src : 'assets/fonts/*',
dest : 'dist/'
src: 'assets/fonts/*',
dest: 'dist/'
}, {
expand: true,
src : 'assets/images/*',
dest : 'dist/',
src: 'assets/images/*',
dest: 'dist/',
filter: 'isFile'
}]
}
},

bump: {
options: {
files : ['package.json'],
commitFiles : ['-a'],
pushTo : 'origin',
files: ['package.json'],
commitFiles: ['-a'],
pushTo: 'origin',
updateConfigs: ['pkg']
}
},
Expand All @@ -204,18 +200,18 @@ module.exports = function (grunt) {
publish: {
command: 'npm publish'
},
rollup : {
rollup: {
command: 'rollup -c rollup.umd.config.js && rollup -c rollup.es2015.config.js'
}
}
});

require('load-grunt-tasks')(grunt);

grunt.registerTask("default", ["eslint", "shell:rollup", "sass", "connect", "watch"]);
grunt.registerTask("build", ["clean", "build-emoji", "eslint", "shell:rollup", "sass", "uglify", "string-replace", "postcss", "copy"]);
grunt.registerTask("default", ["shell:rollup", "sass", "connect", "watch"]);
grunt.registerTask("build", ["clean", "build-emoji", "shell:rollup", "sass", "uglify", "string-replace", "postcss", "copy"]);
grunt.registerTask("build-emoji", ["retinafy", "sprite", "sass"]);
grunt.registerTask("dist", ["clean", "eslint", "shell:rollup", "sass", "uglify", "string-replace", "postcss", "copy"]);
grunt.registerTask("dist", ["clean", "shell:rollup", "sass", "uglify", "string-replace", "postcss", "copy"]);

grunt.registerTask("release", function (option) {
grunt.task.run(["bump-only:" + option, "dist", "conventionalChangelog", "bump-commit", "shell:publish"]);
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,26 @@
"grunt-contrib-uglify": "^1.0.1",
"grunt-contrib-watch": "^1.0.0",
"grunt-conventional-changelog": "^6.1.0",
"grunt-eslint": "^18.0.0",
"grunt-postcss": "^0.8.0",
"grunt-retinafy": "^0.1.5",
"grunt-shell": "^1.1.2",
"grunt-spritesmith": "^6.3.1",
"grunt-string-replace": "^1.2.1",
"load-grunt-tasks": "^3.4.0",
"phantomjs": "^2.1.3",
"rollup": "^0.31.2",
"rollup-plugin-babel": "2.4.0",
"rollup-plugin-commonjs": "^2.2.1",
"rollup-plugin-filesize": "^0.2.1",
"rollup-plugin-npm": "^1.4.0",
"rollup-plugin-uglify": "^0.3.1"
"rollup": "^0.41.4",
"rollup-plugin-buble": "^0.15.0",
"rollup-plugin-commonjs": "^7.0.0",
"rollup-plugin-filesize": "^1.0.1",
"rollup-plugin-node-resolve": "^2.0.0",
"rollup-plugin-uglify": "^1.0.1"
},
"scripts": {
"commit": "git-cz",
"lint": "eslint src/js/**/*.js",
"lintfix": "eslint --fix src/js/**/*.js",
"test": "ava test/**/*.test.js --require babel-register"
"test": "ava test/**/*.test.js --require babel-register",
"build": "rollup -c rollup.umd.config.js && rollup.es2015.config.js"
},
"config": {
"commitizen": {
Expand Down
48 changes: 25 additions & 23 deletions rollup.es2015.config.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
var commonjs = require('rollup-plugin-commonjs');
var npm = require('rollup-plugin-npm');
var pkg = require('./package.json');
var nodeResolve = require('rollup-plugin-node-resolve');
var pkg = require('./package.json');
var filesize = require('rollup-plugin-filesize');

var banner = "/*\n" +
" * " + pkg.name + " - v"+ pkg.version +"\n" +
" * " + pkg.description +"\n" +
" * " + pkg.homepage +"\n" +
" *\n" +
" * Made by "+ pkg.author.name +"\n" +
" * Under "+ pkg.license +" License\n" +
" */\n";
" * " + pkg.name + " - v" + pkg.version + "\n" +
" * " + pkg.description + "\n" +
" * " + pkg.homepage + "\n" +
" *\n" +
" * Made by " + pkg.author.name + "\n" +
" * Under " + pkg.license + " License\n" +
" */\n";


var config = {
entry : 'src/js/main.js',
dest : 'dist/embed.es2015.js',
format : 'es',
banner : banner,
sourceMap : true,
plugins: [
npm({
jsnext : true,
main : true
}),
commonjs({
include: 'node_modules/**'
})
]
entry: 'src/js/main.js',
dest: 'dist/embed.es2015.js',
format: 'es',
banner: banner,
sourceMap: true,
plugins: [
nodeResolve({
jsnext: true,
main: true
}),
commonjs({
include: 'node_modules/**'
}),
filesize()
]
};

module.exports = config;
31 changes: 14 additions & 17 deletions rollup.umd.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var babel = require('rollup-plugin-babel');
var commonjs = require('rollup-plugin-commonjs');
var npm = require('rollup-plugin-npm');
var pkg = require('./package.json');
var filesize = require('rollup-plugin-filesize');
var nodeResolve = require('rollup-plugin-node-resolve');
var pkg = require('./package.json');
var filesize = require('rollup-plugin-filesize');
var buble = require('rollup-plugin-buble')

var banner = "/*\n" +
" * " + pkg.name + " - v" + pkg.version + "\n" +
Expand All @@ -14,24 +14,21 @@ var banner = "/*\n" +
" */\n";

var config = {
entry : 'src/js/main.js',
dest : 'dist/embed.js',
format : 'umd',
banner : banner,
sourceMap : true,
moduleName : 'EmbedJS',
plugins : [
npm({
entry: 'src/js/main.js',
dest: 'dist/embed.js',
format: 'umd',
banner: banner,
sourceMap: true,
moduleName: 'EmbedJS',
plugins: [
nodeResolve({
jsnext: true,
main : true
main: true
}),
commonjs({
include: 'node_modules/**'
}),
babel({
babelrc:false,
presets:['es2015-rollup']
}),
buble(),
filesize()
]
};
Expand Down

0 comments on commit 9e8f4c5

Please sign in to comment.