Skip to content

Commit 1f4a2a2

Browse files
committed
fix: vite's development server alias command compatible(close: #41 )
1 parent dacdb0f commit 1f4a2a2

File tree

5 files changed

+22
-245
lines changed

5 files changed

+22
-245
lines changed

build/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const baseConfig = {
1616
noExternal: ['estree-walker'],
1717
format: ['cjs', 'esm'],
1818
clean: true,
19-
minify: false,
19+
minify: true,
2020
dts: false,
2121
outDir: path.resolve(process.cwd(), '../dist'),
2222

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
"rollup": "^3.19.1",
125125
"simple-git-hooks": "^2.8.1",
126126
"typescript": "5.0.3",
127-
"vite": "^4.0.1",
127+
"vite": "^4.2.1",
128128
"vitest": "^0.29.2"
129129
},
130130
"simple-git-hooks": {

packages/core/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createUnplugin } from 'unplugin'
22
import { NAME } from '@unplugin-vue-cssvars/utils'
33
import { createFilter } from '@rollup/pluginutils'
44
import { parse } from '@vue/compiler-sfc'
5+
import chalk from 'chalk'
56
import { preProcessCSS } from './runtime/pre-process-css'
67
import { getVBindVariableListByPath } from './runtime/process-css'
78
import { initOption } from './option'
@@ -26,7 +27,11 @@ const unplugin = createUnplugin<Options>(
2627
const CSSFileModuleMap = preProcessCSS(userOptions, userOptions.alias)
2728
const vbindVariableList = new Map<string, TMatchVariable>()
2829
let isScriptSetup = false
29-
let isServer = false
30+
if (userOptions.server === undefined) {
31+
console.warn(chalk.yellowBright.bold(`[${NAME}] The server of option is not set, you need to specify whether you are using the development server or building the project`))
32+
console.warn(chalk.yellowBright.bold(`[${NAME}] See: https://github.com/baiwusanyu-c/unplugin-vue-cssvars/blob/master/README.md#option`))
33+
}
34+
let isServer = !!userOptions.server
3035
return [
3136
{
3237
name: NAME,
@@ -52,7 +57,7 @@ const unplugin = createUnplugin<Options>(
5257
}
5358
return code
5459
} catch (err: unknown) {
55-
this.error(`${NAME} ${err}`)
60+
this.error(`[${NAME}] ${err}`)
5661
}
5762
},
5863
vite: {
@@ -83,7 +88,7 @@ const unplugin = createUnplugin<Options>(
8388
}
8489
return code
8590
} catch (err: unknown) {
86-
this.error(`${NAME} ${err}`)
91+
this.error(`[${NAME}] ${err}`)
8792
}
8893
},
8994
},

play/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "module",
55
"version": "0.0.0",
66
"scripts": {
7-
"dev": "vite serve --host",
7+
"dev": "vite --host",
88
"build": "vite build",
99
"preview": "vite preview --host"
1010
},

0 commit comments

Comments
 (0)