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