vite-plugin-blocklet
v0.9.14
Published
The Vite library plugin, which enhanced development of [ArcBlock blocklet](http://developer.blocklet.io/)
Downloads
1,073
Readme
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'});