Skip to content

Commit

Permalink
refactor: change plugin name
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgao365 committed Dec 26, 2023
1 parent 1ce29bb commit 086cbab
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/cdn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from 'node:path';
import fs from 'fs-extra';
import { parse as htmlParser } from 'node-html-parser';
import externalGlobals from 'rollup-plugin-external-globals';
import { CDN_PLUGIN_NAME } from '../constants';
import { type HtmlCdnOptions } from './types';
import { getArrayValue, getModuleConfig, getModulePath } from './util';

Expand All @@ -17,7 +18,7 @@ export function useHtmlCdnPlugin(options: HtmlCdnOptions): PluginOption {
let outDir;

return {
name: '@tomjs:html-cdn',
name: CDN_PLUGIN_NAME,
apply: 'build',
enforce: 'post',
config(userCfg, { command }) {
Expand Down
3 changes: 3 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const CDN_PLUGIN_NAME = 'tomjs:html-cdn';
export const LOADING_PLUGIN_NAME = 'tomjs:html-loading';
export const MINIFY_PLUGIN_NAME = 'tomjs:html-minify';
3 changes: 2 additions & 1 deletion src/loading/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { PluginOption } from 'vite';
import { parse as htmlParser } from 'node-html-parser';
import { LOADING_PLUGIN_NAME } from '../constants';
import loadingHtml from './template';
import { type HtmlLoadingOptions } from './types';

Expand All @@ -15,7 +16,7 @@ const DEFAULT_SELECTOR = '#app';
*/
export function useHtmlLoadingPlugin(options?: boolean | HtmlLoadingOptions): PluginOption {
return {
name: '@tomjs:html-loading',
name: LOADING_PLUGIN_NAME,
enforce: 'post',
transformIndexHtml(html) {
let opts: HtmlLoadingOptions = {};
Expand Down
3 changes: 2 additions & 1 deletion src/minify/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import type { PluginOption } from 'vite';
import { minify as minifyFn } from 'html-minifier-terser';
import { createFilter } from '@rollup/pluginutils';
import { MINIFY_PLUGIN_NAME } from '../constants';
import { type HtmlMinifyOptions } from './types';

export * from './types';
Expand Down Expand Up @@ -39,7 +40,7 @@ async function minifyHtml(html: string, minify: boolean | HtmlMinifyOptions) {
*/
export function useHtmlMinifyPlugin(minify?: boolean | HtmlMinifyOptions): PluginOption {
return {
name: '@tomjs:html-minify',
name: MINIFY_PLUGIN_NAME,
apply: 'build',
enforce: 'post',
async generateBundle(_, outBundle) {
Expand Down

0 comments on commit 086cbab

Please sign in to comment.