Skip to content

Commit

Permalink
Merge pull request ritz078#212 from ritz078/upgrade-build
Browse files Browse the repository at this point in the history
Upgrade build
  • Loading branch information
ritz078 authored Feb 24, 2017
2 parents 231479f + 9e8f4c5 commit 07f095d
Show file tree
Hide file tree
Showing 25 changed files with 599 additions and 619 deletions.
30 changes: 5 additions & 25 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
{
"env": {
"node": true,
"es6": true,
"browser": true
},
"parser": "babel-eslint",
"extends": "eslint:recommended",
"extends": "standard",
"rules": {
"no-multi-spaces": 0,
"key-spacing": 0,
"no-return-assign": 0,
"consistent-return": 0,
"no-shadow": 0,
"comma-dangle": 0,
"no-use-before-define": 0,
"no-empty": 0,
"new-parens": 0,
"no-cond-assign": 0,
"no-fallthrough": 0,
"new-cap": 0,
"no-loop-func": 0,
"no-unreachable": 0,
"no-labels": 0,
"no-process-exit": 0,
"camelcase": 0,
"no-console": 0
"one-var": "off",
"no-tabs": "off",
"no-useless-escape": "off",
"no-new-func": "off"
}
}
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
23 changes: 14 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"cssnano": "^3.4.0",
"cz-conventional-changelog": "^1.1.6",
"es6-promise": "^3.0.2",
"eslint": "^2.5.1",
"eslint": "^3.16.1",
"eslint-config-standard": "^6.2.1",
"eslint-plugin-promise": "^3.4.2",
"eslint-plugin-standard": "^2.0.1",
"fetch-jsonp": "^1.0.0",
"grunt": "^0.4.5",
"grunt-bump": "^0.7.0",
Expand All @@ -70,24 +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",
"test": "ava test/**/*.test.js --require babel-register"
"lint": "eslint src/js/**/*.js",
"lintfix": "eslint --fix src/js/**/*.js",
"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;
Loading

0 comments on commit 07f095d

Please sign in to comment.