Fixed bundle.js size issues
This commit is contained in:
@ -117,6 +117,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-regenerator-runtime": "^6.5.0",
|
"babel-regenerator-runtime": "^6.5.0",
|
||||||
"fsevents": "^1.0.11",
|
"fsevents": "^1.0.11",
|
||||||
|
"ignore-loader": "^0.1.1",
|
||||||
"koa-webpack-dev-middleware": "^1.2.0",
|
"koa-webpack-dev-middleware": "^1.2.0",
|
||||||
"koa-webpack-hot-middleware": "^1.0.3",
|
"koa-webpack-hot-middleware": "^1.0.3",
|
||||||
"node-dev": "^3.1.0",
|
"node-dev": "^3.1.0",
|
||||||
|
@ -6,8 +6,10 @@ import {
|
|||||||
} from '../sequelize';
|
} from '../sequelize';
|
||||||
import {
|
import {
|
||||||
convertToMarkdown,
|
convertToMarkdown,
|
||||||
truncateMarkdown,
|
|
||||||
} from '../../src/utils/markdown';
|
} from '../../src/utils/markdown';
|
||||||
|
import {
|
||||||
|
truncateMarkdown,
|
||||||
|
} from '../utils/truncate';
|
||||||
import Atlas from './Atlas';
|
import Atlas from './Atlas';
|
||||||
import Team from './Team';
|
import Team from './Team';
|
||||||
import User from './User';
|
import User from './User';
|
||||||
|
18
server/utils/truncate.js
Normal file
18
server/utils/truncate.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import truncate from 'truncate-html';
|
||||||
|
import { convertToMarkdown } from '../../src/utils/markdown';
|
||||||
|
|
||||||
|
truncate.defaultOptions = {
|
||||||
|
stripTags: false,
|
||||||
|
ellipsis: '...',
|
||||||
|
decodeEntities: false,
|
||||||
|
excludes: ['h1', 'pre', ],
|
||||||
|
};
|
||||||
|
|
||||||
|
const truncateMarkdown = (text, length) => {
|
||||||
|
const html = convertToMarkdown(text);
|
||||||
|
return truncate(html, length);
|
||||||
|
};
|
||||||
|
|
||||||
|
export {
|
||||||
|
truncateMarkdown,
|
||||||
|
};
|
@ -1,5 +1,4 @@
|
|||||||
import slug from 'slug';
|
import slug from 'slug';
|
||||||
import truncate from 'truncate-html';
|
|
||||||
import marked, { Renderer } from 'marked';
|
import marked, { Renderer } from 'marked';
|
||||||
import highlight from 'highlight.js';
|
import highlight from 'highlight.js';
|
||||||
|
|
||||||
@ -34,25 +33,11 @@ marked.setOptions({
|
|||||||
smartypants: true,
|
smartypants: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: This is syncronous and can be costly,
|
// TODO: This is syncronous and can be costly
|
||||||
// should be performed outside http request
|
|
||||||
const convertToMarkdown = (text) => {
|
const convertToMarkdown = (text) => {
|
||||||
return marked(text);
|
return marked(text);
|
||||||
};
|
};
|
||||||
|
|
||||||
truncate.defaultOptions = {
|
|
||||||
stripTags: false,
|
|
||||||
ellipsis: '...',
|
|
||||||
decodeEntities: false,
|
|
||||||
excludes: ['h1', 'pre', ],
|
|
||||||
};
|
|
||||||
|
|
||||||
const truncateMarkdown = (text, length) => {
|
|
||||||
const html = convertToMarkdown(text);
|
|
||||||
return truncate(html, length);
|
|
||||||
};
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
convertToMarkdown,
|
convertToMarkdown,
|
||||||
truncateMarkdown,
|
|
||||||
};
|
};
|
||||||
|
@ -34,6 +34,13 @@ module.exports = {
|
|||||||
test: /\.woff$/,
|
test: /\.woff$/,
|
||||||
loader: 'url-loader?limit=1&mimetype=application/font-woff&name=public/fonts/[name].[ext]'
|
loader: 'url-loader?limit=1&mimetype=application/font-woff&name=public/fonts/[name].[ext]'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Excludes
|
||||||
|
{
|
||||||
|
// slug
|
||||||
|
test: /unicode/,
|
||||||
|
loader: 'ignore-loader',
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
|
Reference in New Issue
Block a user