@react-foundry/vite-html-react
v0.1.7
Published
A Vite plugin for importing HTML files as React components.
Readme
React Foundry - Vite HTML React
A Vite plugin for importing HTML files as React components.
Using this package
First install the package into your project:
npm install -D @react-foundry/vite-html-reactThen use it in your vite.config.js as follows:
import { defineConfig } from 'vite';
import html from '@react-foundry/vite-html-react';
export default defineConfig({
plugins: [
html({
extensions: ['.htm']
}),
[...]
],
[...]
});
[...]You can then import HTML files in the form of a React component:
import Html from './path/to/content.htm';
const Component = () => (
<Html />
);Typically, the HTML file would only contain a portion of your HTML, rather than a full page.
Note:: Vite doesn't allow for .html files to be used; by default we us .htm instead.
Working on this package
Before working on this package you must install its dependencies using the following command:
pnpm installBuilding
Build the package by compiling the source code.
npm run buildClean-up
Remove any previously built files.
npm run clean