Skip to content

Commit 209e9e4

Browse files
Bart LedouxBart Ledoux
authored andcommitted
fix: allow ssr usage of vue-live
1 parent 3516c17 commit 209e9e4

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

demo/App.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ import codeTemplate from "!!raw-loader!./assets/PureTemplate.html";
110110
import codeChicago from "!!raw-loader!./assets/Chicago.jsx";
111111
import all from "./assets/chicagoNeighbourhoods";
112112
import "prismjs/themes/prism-tomorrow.css";
113-
//vue-prism-editor dependency
114-
import "vue-prism-editor/dist/prismeditor.min.css";
115113
116114
import GithubCorners from "vue-github-corners";
117115

rollup.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as path from "path";
22
import commonjs from "@rollup/plugin-commonjs";
33
import babel from "@rollup/plugin-babel";
4+
import node from "@rollup/plugin-node-resolve";
45
import vue from "rollup-plugin-vue";
56
import css from "rollup-plugin-css-only";
67
import analyze from "rollup-plugin-analyzer";
@@ -12,6 +13,7 @@ const rootConfig = {
1213
input: resolve("./src/index.js"),
1314
plugins: [
1415
commonjs(),
16+
node(),
1517
babel({
1618
babelrc: false,
1719
// avoid using babel.config.js. It kills es6 modules for ie compatibility
@@ -55,6 +57,9 @@ export default [
5557
file: pkg.main,
5658
exports: "named", // remove warning about mixed exports
5759
},
58-
plugins: [...rootConfig.plugins, vue({ template: { optimizeSSR: true } })],
60+
plugins: [
61+
...rootConfig.plugins,
62+
vue({ css: false, template: { optimizeSSR: true } }),
63+
],
5964
},
6065
];

src/Editor.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import "prismjs/components/prism-clike";
1818
import "prismjs/components/prism-markup";
1919
import "prismjs/components/prism-javascript";
2020
import "prismjs/components/prism-jsx";
21+
import "vue-prism-editor/dist/prismeditor.min.css";
2122
2223
import debounce from "debounce";
2324
import getScript from "./utils/getScript";
@@ -40,14 +41,20 @@ const highlight = (lang, jsxInExamples) => {
4041
return scriptCodeHighlighted;
4142
}
4243
const templateCode = code.slice(scriptCode.length);
44+
const templateHighlighted = prismHighlight(templateCode, languages["html"], lang)
4345
return (
4446
scriptCodeHighlighted +
45-
prismHighlight(templateCode, languages["html"], lang)
47+
templateHighlighted
4648
);
4749
};
4850
} else {
49-
const langScheme = languages[lang];
50-
return (code) => prismHighlight(code, langScheme, lang);
51+
return (code) => {
52+
const langScheme = languages[lang];
53+
if(!langScheme){
54+
return code
55+
}
56+
return prismHighlight(code, langScheme, lang);
57+
}
5158
}
5259
};
5360

0 commit comments

Comments
 (0)