iconagency/wordpress_vite

IconAgency WordPress Vite 插件

1.0.4 2022-05-17 00:52 UTC

This package is auto-updated.

Last update: 2024-09-20 13:04:00 UTC


README

集成了 Vite HMR 和 dist 与 WordPress。

安装

  "require": {
    "iconagency/wordpress_vite": "^1.0.0",
  },

添加 style.css 需求

将 vite 配置添加到您的 theme/style.css

/*
Theme Name:         YourTheme 
Theme URI:          https://your.domain.com/
Description:        YourTheme Wordpress theme
Version:            2.0.0
Author:             You
Author URI:         https://your.domain.com/
License:            MIT License
License URI:        https://open-source.org.cn/licenses/MIT

Vite Client:        https://:8000/@vite/client
Vite Entry:         js/app.js
Vite Dist:          dist/
*/

示例 vite 配置

import { defineConfig } from "vite";

export default ({ mode }) => {
  return defineConfig({
    base: mode === "development" ? "/" : "/app/themes/iconagency/dist/",

    build: {
      manifest: true,
      rollupOptions: {
        input: ["js/app.js"],
        output: { entryFileNames: `[name].js` },
      },
    },

    server: {
      cors: true,
      port: 8000,
      hmr: {
        host: "localhost",
        protocol: "ws",
      },
    },
  });
};

开发模式

WP_DEBUG 应设置为 true 以启用开发服务器客户端。