Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update vite #3225

Merged
merged 3 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/sandbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"ts-loader": "^9.3.0",
"ts-node": "^10.8.1",
"typescript": "^4.3.2",
"vite": "^2.4.4",
"vite": "^4.2.1",
"vitest": "*",
"vue-bundle-renderer": "0.4.1",
"vue-tsc": "^0.38.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/tailwind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
"registry": "https://registry.npmjs.org"
},
"devDependencies": {
"vite": "^2.9.8"
"vite": "^4.2.1"
}
}
13 changes: 8 additions & 5 deletions packages/ui/build/plugins/append-component-css.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { existsSync } from 'fs'
import { extname, dirname, basename } from 'path'
import { extname, dirname, basename, relative, resolve } from 'path'
import { createDistTransformPlugin } from './fabrics/create-dist-transform-plugin'

const parsePath = (path: string) => {
Expand Down Expand Up @@ -27,15 +27,18 @@ export const appendComponentCss = createDistTransformPlugin({

dir: (outDir) => `${outDir}/src/components`,

transform: (componentContent, path) => {
transform (componentContent, path) {
rustem-nasyrov marked this conversation as resolved.
Show resolved Hide resolved
if (!isVuesticComponent(path)) { return }

const { name, dir } = parsePath(path)

const cssFilePath = `${dir}/${name}.css`
const distPath = resolve(this.outDir, '..', '..')
rustem-nasyrov marked this conversation as resolved.
Show resolved Hide resolved
const relativeDistPath = relative(dir, distPath)
const relativeFilePath = relativeDistPath + '/' + name.replace(/-.*$/, '') + '.css'

if (!existsSync(cssFilePath)) { return }
if (!existsSync(resolve(dir, relativeFilePath))) { return }

return appendBeforeSourceMapComment(componentContent, `\nimport './${name}.css';`)
return appendBeforeSourceMapComment(componentContent, `\nimport '${relativeFilePath}';`)
},

})
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { readdir, readFile, writeFile, lstat } from 'fs/promises'

type Nothing = null | undefined | void
type TransformFnResult = string | Nothing
type TransformFn = (content: string, path: string) => TransformFnResult | Promise<TransformFnResult>
type TransformFn = (this: { outDir: string }, content: string, path: string) => TransformFnResult | Promise<TransformFnResult>

export const createDistTransformPlugin = (options: {
name: string,
Expand All @@ -23,7 +23,7 @@ export const createDistTransformPlugin = (options: {

const content = await readFile(currentPath, 'utf8')

const result = await options.transform(content, currentPath)
const result = await options.transform.call({ outDir }, content, currentPath)
rustem-nasyrov marked this conversation as resolved.
Show resolved Hide resolved

if (!result) { return }

Expand Down
6 changes: 3 additions & 3 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@types/yargs": "^17.0.10",
"@typescript-eslint/eslint-plugin": "^4.12.0",
"@typescript-eslint/parser": "^4.12.0",
"@vitejs/plugin-vue": "^2.3.2",
"@vitejs/plugin-vue": "^4.1.0",
"@vue/cli-plugin-babel": "^5.0.0-alpha.3",
"@vue/cli-plugin-e2e-cypress": "^5.0.0-alpha.3",
"@vue/cli-plugin-eslint": "^5.0.0-alpha.3",
Expand Down Expand Up @@ -110,8 +110,8 @@
"stylelint-config-standard": "^22.0.0",
"ts-loader": "^8.0.14",
"typescript": "4.7.4",
"vite": "^2.9.8",
"vite-plugin-chunk-split": "^0.2.2",
"vite": "^4.2.1",
"vite-plugin-chunk-split": "^0.4.7",
"vitest": "^0.18.1",
"vue": "^3.0.4",
"vue-book": "0.2.0-alpha.0",
Expand Down
Loading