client/build: roll back to underscore
lodash adds extra 50K for no benefit.
This commit is contained in:
parent
98c6128829
commit
94a228b1e7
|
@ -72,7 +72,7 @@ function minifyHtml(html) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function bundleHtml(config) {
|
function bundleHtml(config) {
|
||||||
const lodash = require('lodash');
|
const underscore = require('underscore');
|
||||||
const babelify = require('babelify');
|
const babelify = require('babelify');
|
||||||
const baseHtml = fs.readFileSync('./html/index.htm', 'utf-8');
|
const baseHtml = fs.readFileSync('./html/index.htm', 'utf-8');
|
||||||
const finalHtml = baseHtml
|
const finalHtml = baseHtml
|
||||||
|
@ -83,12 +83,12 @@ function bundleHtml(config) {
|
||||||
|
|
||||||
glob('./html/**/*.tpl', {}, (er, files) => {
|
glob('./html/**/*.tpl', {}, (er, files) => {
|
||||||
let compiledTemplateJs = '\'use strict\'\n';
|
let compiledTemplateJs = '\'use strict\'\n';
|
||||||
compiledTemplateJs += 'let _ = require(\'lodash\');';
|
compiledTemplateJs += 'let _ = require(\'underscore\');';
|
||||||
compiledTemplateJs += 'let templates = {};';
|
compiledTemplateJs += 'let templates = {};';
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
const name = path.basename(file, '.tpl').replace(/_/g, '-');
|
const name = path.basename(file, '.tpl').replace(/_/g, '-');
|
||||||
const templateText = minifyHtml(fs.readFileSync(file, 'utf-8'));
|
const templateText = minifyHtml(fs.readFileSync(file, 'utf-8'));
|
||||||
const functionText = lodash.template(
|
const functionText = underscore.template(
|
||||||
templateText, {variable: 'ctx'}).source;
|
templateText, {variable: 'ctx'}).source;
|
||||||
compiledTemplateJs += `templates['${name}'] = ${functionText};`;
|
compiledTemplateJs += `templates['${name}'] = ${functionText};`;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ function bundleCss() {
|
||||||
function bundleJs(config) {
|
function bundleJs(config) {
|
||||||
const browserify = require('browserify');
|
const browserify = require('browserify');
|
||||||
const external = [
|
const external = [
|
||||||
'lodash',
|
'underscore',
|
||||||
'superagent',
|
'superagent',
|
||||||
'mousetrap',
|
'mousetrap',
|
||||||
'js-cookie',
|
'js-cookie',
|
||||||
|
|
|
@ -17,14 +17,14 @@
|
||||||
"html-minifier": "^1.3.1",
|
"html-minifier": "^1.3.1",
|
||||||
"js-cookie": "^2.1.0",
|
"js-cookie": "^2.1.0",
|
||||||
"js-yaml": "^3.5.5",
|
"js-yaml": "^3.5.5",
|
||||||
"lodash": "^4.12.0",
|
|
||||||
"merge": "^1.2.0",
|
"merge": "^1.2.0",
|
||||||
"mousetrap": "^1.5.3",
|
"mousetrap": "^1.5.3",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"page": "^1.7.1",
|
"page": "^1.7.1",
|
||||||
"stylus": "^0.54.2",
|
"stylus": "^0.54.2",
|
||||||
"superagent": "^1.8.3",
|
"superagent": "^1.8.3",
|
||||||
"uglify-js": "git://github.com/mishoo/UglifyJS2.git#harmony"
|
"uglify-js": "git://github.com/mishoo/UglifyJS2.git#harmony",
|
||||||
|
"underscore": "^1.8.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"watch": "latest"
|
"watch": "latest"
|
||||||
|
|
Loading…
Reference in New Issue