Add optimize-js to build toolchain

This commit is contained in:
Paulus Schoutsen 2016-09-19 21:09:29 -07:00
parent 8394f10ca4
commit 7d32ee0912
3 changed files with 13 additions and 4 deletions

View File

@ -11,15 +11,15 @@
"clean": "rm -rf build/* build-temp/*", "clean": "rm -rf build/* build-temp/*",
"js_dev": "script/gen-service-worker.js && npm run watch_ru_all", "js_dev": "script/gen-service-worker.js && npm run watch_ru_all",
"js_dev_demo": "BUILD_DEMO=1 npm run watch_ru_all", "js_dev_demo": "BUILD_DEMO=1 npm run watch_ru_all",
"js_prod": "BUILD_DEV=0 npm run ru_all", "js_prod": "BUILD_DEV=0 npm run ru_all && script/optimize-js.js",
"js_demo": "BUILD_DEV=0 BUILD_DEMO=1 npm run ru_all", "js_demo": "BUILD_DEV=0 BUILD_DEMO=1 npm run ru_all",
"frontend_html": "script/vulcanize.js", "frontend_html": "script/vulcanize.js",
"frontend_prod": "npm run js_prod && npm run frontend_html", "frontend_prod": "npm run js_prod && npm run frontend_html",
"frontend_demo": "npm run js_demo && npm run frontend_html", "frontend_demo": "npm run js_demo && npm run frontend_html",
"ru_all": "npm run ru_core | npm run ru_demo", "ru_all": "npm run ru_core && npm run ru_demo",
"ru_core": "rollup --config rollup/core.js", "ru_core": "rollup --config rollup/core.js",
"ru_demo": "rollup --config rollup/demo.js", "ru_demo": "rollup --config rollup/demo.js",
"watch_ru_all": "npm run watch_ru_core | npm run watch_ru_demo", "watch_ru_all": "npm run watch_ru_core && npm run watch_ru_demo",
"watch_ru_core": "rollup --config rollup/core.js --watch", "watch_ru_core": "rollup --config rollup/core.js --watch",
"watch_ru_demo": "rollup --config rollup/demo.js --watch", "watch_ru_demo": "rollup --config rollup/demo.js --watch",
"lint_js": "eslint src panels --ext html", "lint_js": "eslint src panels --ext html",
@ -43,6 +43,7 @@
"eslint-plugin-import": "^1.15.0", "eslint-plugin-import": "^1.15.0",
"html-minifier": "^3.0.3", "html-minifier": "^3.0.3",
"hydrolysis": "^1.24.1", "hydrolysis": "^1.24.1",
"optimize-js": "^1.0.0",
"polymer-cli": "^0.16.0", "polymer-cli": "^0.16.0",
"polymer-lint": "^0.8.3", "polymer-lint": "^0.8.3",
"rollup": "^0.35.12", "rollup": "^0.35.12",

8
script/optimize-js.js Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env node
var fs = require('fs');
var optimizeJs = require('optimize-js');
var core = fs.readFileSync('build/core.js', 'utf-8');
core = optimizeJs(core);
fs.writeFileSync('build/core.js', core);

View File

@ -1,4 +1,4 @@
#! /usr/bin/env node #!/usr/bin/env node
var Vulcanize = require('vulcanize'); var Vulcanize = require('vulcanize');
var minify = require('html-minifier'); var minify = require('html-minifier');