Skip to content

Commit 8bb978d

Browse files
authored
Perf: highlight.js --> prism (#1865)
* perf: highlight.js --> prism * fix: wrong mentions route
1 parent 9670ecb commit 8bb978d

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

build/dev.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ let { componentName } = require('./config').dev;
2828
const componentsInPrototype = ['Modal', 'message', 'notification'];
2929

3030
const MAIN_TEMPLATE = `import 'babel-polyfill';
31-
import 'highlight.js/styles/solarized-light.css';
3231
import Vue from 'vue';
3332
import Vuex from 'vuex';
3433
import VueI18n from 'vue-i18n';

build/webpack.base.conf.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const path = require('path');
2-
const hljs = require('highlight.js');
2+
const Prism = require('prismjs');
33
const Token = require('markdown-it/lib/token');
44
const cheerio = require('cheerio');
55
const WebpackBar = require('webpackbar');
@@ -43,12 +43,12 @@ const replaceDelimiters = function(str) {
4343
*/
4444

4545
const renderHighlight = function(str, lang) {
46-
if (!(lang && hljs.getLanguage(lang))) {
46+
if (!(lang && Prism.languages[lang])) {
4747
return '';
4848
}
4949

5050
try {
51-
return replaceDelimiters(hljs.highlight(lang, str, true).value);
51+
return replaceDelimiters(Prism.highlight(str, Prism.languages[lang], lang));
5252
} catch (err) {}
5353
};
5454

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
"postcss-loader": "^3.0.0",
140140
"prettier": "^1.18.2",
141141
"pretty-quick": "^2.0.0",
142+
"prismjs": "^1.19.0",
142143
"querystring": "^0.2.0",
143144
"raw-loader": "^4.0.0",
144145
"reqwest": "^2.0.5",
@@ -216,4 +217,4 @@
216217
"lib/**/style/*",
217218
"*.less"
218219
]
219-
}
220+
}

site/demoRoutes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default [
8080
component: () => import('../antdv-demo/input/demo/index.vue'),
8181
},
8282
{
83-
path: 'mentions-cn',
83+
path: 'mentions',
8484
component: () => import('../antdv-demo/mentions/demo/index.vue'),
8585
},
8686
{

site/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'babel-polyfill';
22
import '../components/style.js';
33
import './index.less';
44
import 'nprogress/nprogress.css';
5-
import 'highlight.js/styles/solarized-light.css';
65
import Vue from 'vue';
76
import Vuex from 'vuex';
87
import VueI18n from 'vue-i18n';

0 commit comments

Comments
 (0)