1.0.7 • Published 2 months ago

vite-plugin-dtemplate v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Install

yarn add vite-plugin-dtemplate

Usage

In vite.config.ts:

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import { dTemplatePlugin } from "vite-plugin-dtemplate";

export default defineConfig({
    plugins: [
        react(),
        dTemplatePlugin(),
    ],
});

Templates

Template files follow a specific extension pattern (.d.template), for example:

.env

VITE_APPLICATION_NAME="VITE"

example.d.template

Hello world by <<#VITE_APPLICATION_NAME>>
{{endLine}}

index.tsx

import React from "react";
import example from "./example.d.template";

export const App: React.FC = () => {
    return (
        <div>
            {example}
            {/* RESULT:
                Hello world by VITE
                {{endLine}}
            */}
        </div>
    );
};

OR

import React from "react";
import example from "./example.d.template";
import { fillTemplate } from "vite-plugin-dtemplate/utils";

export const App: React.FC = () => {
    return (
        <div>
            {fillTemplate({
                template: example,
                params: {
                    endLine: "end line..."
                }
            })}
            {/* RESULT:
                Hello world by VITE
                end line...
            */}
        </div>
    );
};

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License.

1.0.7

2 months ago

1.0.6

2 months ago

1.0.5

2 months ago

1.0.4

2 months ago

1.0.3

2 months ago

1.0.2

2 months ago

1.0.1

2 months ago

1.0.0

2 months ago