vite-plugin-blocklet

0.9.4 • Public • Published

vite-plugin-blocklet

The Vite library plugin, which enhanced development of ArcBlock blocklet

Use examples

Example of front-end project

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { createBlockletPlugin } from 'vite-plugin-blocklet';
import { nodePolyfills } from 'vite-plugin-node-polyfills';

// https://vitejs.dev/config/
export default defineConfig(async () => {
  return {
    plugins: [react(), createBlockletPlugin(), nodePolyfills({ protocolImports: true })],
  };
});

Example of back-end project

api/index.js

const express = require('express');
const app = express();

module.exports = { app };

api/dev.js

const { setupClient } = require('vite-plugin-blocklet');
const { app } = require('./index');

setupClient(app);

package.json

"start": "NODE_ENV=development nodemon api/dev.js -w api",

Basically, you vite.config.js file should be in the root of project folders, if you need setup a custom vite config file, you should change your npm scripts, like:

package.json

"start": "NODE_ENV=development nodemon api/dev.js -w api -- --config=./config/vite.config.js",

Or you can just pass vite config file path to setupClient function, like this:

const { setupClient } = require('vite-plugin-blocklet');
const { app } = require('./index');

setupClient(app, { configFile: './config/vite.config.js'});

Readme

Keywords

none

Package Sidebar

Install

npm i vite-plugin-blocklet

Weekly Downloads

135

Version

0.9.4

License

ISC

Unpacked Size

58.1 kB

Total Files

13

Last publish

Collaborators

  • wangshijun
  • lancelot_lewis