factor out plugin call
this will make it easier to do per-file replacements
This commit is contained in:
parent
7d74cf62c3
commit
cb2734e9a6
@ -1,5 +1,6 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import pluginReplace from '@rollup/plugin-replace';
|
import pluginReplace from '@rollup/plugin-replace';
|
||||||
|
import type { RollupReplaceOptions } from '@rollup/plugin-replace';
|
||||||
import pluginVue from '@vitejs/plugin-vue';
|
import pluginVue from '@vitejs/plugin-vue';
|
||||||
import { type UserConfig, defineConfig } from 'vite';
|
import { type UserConfig, defineConfig } from 'vite';
|
||||||
|
|
||||||
@ -59,6 +60,17 @@ function toBase62(n: number): string {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function iconsReplace(opts: RollupReplaceOptions) {
|
||||||
|
return pluginReplace({
|
||||||
|
...opts,
|
||||||
|
preventAssignment: false,
|
||||||
|
// only replace these strings after a quote, remove a ` ti-fw`
|
||||||
|
// it if happens to be just after, and make sure they're
|
||||||
|
// followed by a word-boundary that's not a dash
|
||||||
|
delimiters: ['(?<=["\'])', '(?: ti-fw)?\\b(?!-)'],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function getConfig(): UserConfig {
|
export function getConfig(): UserConfig {
|
||||||
return {
|
return {
|
||||||
base: '/vite/',
|
base: '/vite/',
|
||||||
@ -71,12 +83,7 @@ export function getConfig(): UserConfig {
|
|||||||
pluginVue(),
|
pluginVue(),
|
||||||
pluginUnwindCssModuleClassName(),
|
pluginUnwindCssModuleClassName(),
|
||||||
pluginJson5(),
|
pluginJson5(),
|
||||||
pluginReplace({
|
iconsReplace({
|
||||||
preventAssignment: false,
|
|
||||||
// only replace these strings after a quote, remove a ` ti-fw`
|
|
||||||
// it if happens to be just after, and make sure they're
|
|
||||||
// followed by a word-boundary that's not a dash
|
|
||||||
delimiters: ['(?<=["\'])', '(?: ti-fw)?\\b(?!-)'],
|
|
||||||
values: {
|
values: {
|
||||||
'ti ti-terminal-2': 'ph-terminal-window ph-bold ph-lg',
|
'ti ti-terminal-2': 'ph-terminal-window ph-bold ph-lg',
|
||||||
'ti ti-download': 'ph-download ph-bold ph-lg',
|
'ti ti-download': 'ph-download ph-bold ph-lg',
|
||||||
|
Loading…
Reference in New Issue
Block a user