HTML
32 | {html} 33 |ToC
34 | {toc.map((h,i) =>ReactComponent
36 |raw markdown
38 |39 | {markdown} 40 |41 |
ite is an opinionated web dev build tool that serves your code via native ES Module imports during dev and bundles it with Rollup for production.
" 92 | ``` 93 | 94 |Hello Vite + React!
15 |16 | 17 |
18 |
19 | Edit App.jsx
and save to test HMR updates.
20 |
39 | {markdown} 40 |41 |
{{ line[0] }} | 8 |{{ line[1] }} |
9 |
Edit components/HelloWorld.vue
to test hot module replacement.
tags become138 | root.forEach((node: DomHandlerNode) => { 139 | if (node instanceof Element) { 140 | if (['pre', 'code'].includes(node.tagName)) { 141 | node.attribs['v-pre'] = 'true' 142 | } 143 | } 144 | }) 145 | 146 | // Anytag becomes
excepting under `
` 147 | const markCodeAsPre = (node: DomHandlerNode): void => { 148 | if (node instanceof Element) { 149 | if (node.tagName === 'code') node.attribs['v-pre'] = 'true' 150 | if (node.childNodes.length > 0) node.childNodes.forEach(markCodeAsPre) 151 | } 152 | } 153 | root.forEach(markCodeAsPre) 154 | 155 | const { code: compiledVueCode } = (await import('@vue/compiler-sfc')).compileTemplate({ source: DomUtils.getOuterHTML(root, { decodeEntities: true }), filename: id, id }) 156 | content.addContext(compiledVueCode.replace('\nexport function render(', '\nfunction vueRender(') + `\nconst VueComponent = { render: vueRender }\nVueComponent.__hmrId = ${JSON.stringify(id)}\nconst VueComponentWith = (components) => ({ components, render: vueRender })\n`) 157 | content.addExporting('VueComponent') 158 | content.addExporting('VueComponentWith') 159 | } 160 | 161 | return { 162 | code: content.export(), 163 | } 164 | } 165 | 166 | export const plugin = (options: PluginOptions = {}): Plugin => { 167 | return { 168 | name: 'vite-plugin-markdown', 169 | enforce: 'pre', 170 | transform (code, id) { 171 | return tf(code, id, options) 172 | }, 173 | } 174 | } 175 | 176 | export default plugin 177 | -------------------------------------------------------------------------------- /test/acceptance/cypress.json: -------------------------------------------------------------------------------- 1 | { 2 | "integrationFolder": "test/acceptance/integration", 3 | "testFiles": "**/*_spec.*", 4 | "fixturesFolder": "test/acceptance/fixtures", 5 | "pluginsFile": "test/acceptance/plugins", 6 | "screenshotsFolder": "test/acceptance/screenshots", 7 | "supportFile": "test/acceptance/support/index.js", 8 | "video": false 9 | } 10 | -------------------------------------------------------------------------------- /test/acceptance/integration/vue_spec.js: -------------------------------------------------------------------------------- 1 | describe('My First Test', () => { 2 | it('Does not do much!', () => { 3 | expect(true).to.equal(true) 4 | }) 5 | }) 6 | -------------------------------------------------------------------------------- /test/acceptance/plugins/index.js: -------------------------------------------------------------------------------- 1 | ///2 | // *********************************************************** 3 | // This example plugins/index.js can be used to load plugins 4 | // 5 | // You can change the location of this file or turn off loading 6 | // the plugins file with the 'pluginsFile' configuration option. 7 | // 8 | // You can read more here: 9 | // https://on.cypress.io/plugins-guide 10 | // *********************************************************** 11 | 12 | // This function is called when a project is opened or re-opened (e.g. due to 13 | // the project's config changing) 14 | 15 | /** 16 | * @type {Cypress.PluginConfig} 17 | */ 18 | module.exports = (on, config) => { 19 | // `on` is used to hook into various events Cypress emits 20 | // `config` is the resolved Cypress config 21 | } 22 | -------------------------------------------------------------------------------- /test/acceptance/support/commands.js: -------------------------------------------------------------------------------- 1 | // *********************************************** 2 | // This example commands.js shows you how to 3 | // create various custom commands and overwrite 4 | // existing commands. 5 | // 6 | // For more comprehensive examples of custom 7 | // commands please read more here: 8 | // https://on.cypress.io/custom-commands 9 | // *********************************************** 10 | // 11 | // 12 | // -- This is a parent command -- 13 | // Cypress.Commands.add("login", (email, password) => { ... }) 14 | // 15 | // 16 | // -- This is a child command -- 17 | // Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) 18 | // 19 | // 20 | // -- This is a dual command -- 21 | // Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) 22 | // 23 | // 24 | // -- This will overwrite an existing command -- 25 | // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) 26 | -------------------------------------------------------------------------------- /test/acceptance/support/index.js: -------------------------------------------------------------------------------- 1 | // *********************************************************** 2 | // This example support/index.js is processed and 3 | // loaded automatically before your test files. 4 | // 5 | // This is a great place to put global configuration and 6 | // behavior that modifies Cypress. 7 | // 8 | // You can change the location of this file or turn off 9 | // automatically serving support files with the 10 | // 'supportFile' configuration option. 11 | // 12 | // You can read more here: 13 | // https://on.cypress.io/configuration 14 | // *********************************************************** 15 | 16 | // Import commands.js using ES2015 syntax: 17 | import './commands' 18 | 19 | // Alternatively you can use CommonJS syntax: 20 | // require('./commands') 21 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2022", 4 | "moduleResolution": "Node16", 5 | "strict": true, 6 | "declaration": true, 7 | "noUnusedLocals": true, 8 | "esModuleInterop": true, 9 | "outDir": "dist", 10 | "module": "Node16", 11 | "lib": ["ES2022", "DOM"], 12 | "sourceMap": true 13 | }, 14 | "include": ["./src"] 15 | } 16 | --------------------------------------------------------------------------------