Skip to content

Commit

Permalink
chore: release 3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Jan 27, 2022
1 parent af57412 commit fd78151
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 23 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"res": true,
"screenshots": true,
"yarn-error.log": true,
"**/pnpm-lock.yaml": true,
"**/.yarn": true
},
"files.exclude": {
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [3.0.2](https://github.com/vbenjs/vite-plugin-html/compare/v3.0.0...v3.0.2) (2022-01-27)

### Bug Fixes

- fs-extra no longer exports existsSync ([#25](https://github.com/vbenjs/vite-plugin-html/issues/25)) ([d6614da](https://github.com/vbenjs/vite-plugin-html/commit/d6614dae2ab5d2f53d54ec480e1212613819186b))
- make sure template defaults are correct ([697626c](https://github.com/vbenjs/vite-plugin-html/commit/697626cb62db42c1853788ac4019a834822b19e5))

## [3.0.1](https://github.com/vbenjs/vite-plugin-html/compare/v3.0.0...v3.0.1) (2022-01-27)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-html-monorepo",
"version": "3.0.1",
"version": "3.0.2",
"private": true,
"scripts": {
"stub": "pnpm run prepack --filter ./packages -- --stub",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-html",
"version": "3.0.1",
"version": "3.0.2",
"description": "A plugin for vite to Minimize index.html and use lodash.template template syntax in index.html",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
Expand Down
15 changes: 7 additions & 8 deletions packages/core/src/htmlPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { ResolvedConfig, Plugin, TransformResult, normalizePath } from 'vite'
import type { ResolvedConfig, Plugin, TransformResult } from 'vite'
import type { InjectOptions, PageOption, Pages, UserOptions } from './typing'
import { render } from 'ejs'
import { cleanUrl, isDirEmpty, loadEnv } from './utils'
import { htmlFilter } from './utils/createHtmlFilter'
import { mergeConfig } from 'vite'
import { mergeConfig, normalizePath } from 'vite'
import { parse } from 'node-html-parser'
import fsExtra from 'fs-extra'
const { pathExistsSync, readFile, move, remove } = fsExtra
import fse from 'fs-extra'
import { resolve, dirname, basename } from 'pathe'
import fg from 'fast-glob'
import consola from 'consola'
Expand Down Expand Up @@ -115,7 +114,7 @@ export function createPlugin(userOptions: UserOptions = {}): Plugin {

await Promise.all(
htmlFiles.map((file) =>
move(file, resolve(cwd, basename(file)), { overwrite: true }),
fse.move(file, resolve(cwd, basename(file)), { overwrite: true }),
),
)

Expand All @@ -127,7 +126,7 @@ export function createPlugin(userOptions: UserOptions = {}): Plugin {
htmlDirs.map(async (item) => {
const isEmpty = await isDirEmpty(item)
if (isEmpty) {
return remove(item)
return fse.remove(item)
}
}),
)
Expand Down Expand Up @@ -271,8 +270,8 @@ export function getHtmlPath(page: PageOption, root: string) {
}

export async function readHtml(path: string) {
if (!pathExistsSync(path)) {
if (!fse.pathExistsSync(path)) {
throw new Error(`html is not exist in ${path}`)
}
return await readFile(path).then((buffer) => buffer.toString())
return await fse.readFile(path).then((buffer) => buffer.toString())
}
11 changes: 5 additions & 6 deletions packages/core/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { expand } from 'dotenv-expand'
import dotenv from 'dotenv'
import { join, dirname } from 'pathe'
import fsExtra from 'fs-extra'
const { pathExistsSync, readFileSync, statSync, readdir } = fsExtra
import fse from 'fs-extra'

export function loadEnv(
mode: string,
Expand All @@ -27,7 +26,7 @@ export function loadEnv(
for (const file of envFiles) {
const path = lookupFile(envDir, [file], true)
if (path) {
const parsed = dotenv.parse(readFileSync(path), {
const parsed = dotenv.parse(fse.readFileSync(path), {
debug: !!process.env.DEBUG || undefined,
})

Expand Down Expand Up @@ -60,8 +59,8 @@ export function lookupFile(
): string | undefined {
for (const format of formats) {
const fullPath = join(dir, format)
if (pathExistsSync(fullPath) && statSync(fullPath).isFile()) {
return pathOnly ? fullPath : readFileSync(fullPath, 'utf-8')
if (fse.pathExistsSync(fullPath) && fse.statSync(fullPath).isFile()) {
return pathOnly ? fullPath : fse.readFileSync(fullPath, 'utf-8')
}
}
const parentDir = dirname(dir)
Expand All @@ -77,7 +76,7 @@ export function cleanUrl(url: string): string {
}

export async function isDirEmpty(dir: string) {
return readdir(dir).then((files) => {
return fse.readdir(dir).then((files) => {
return files.length === 0
})
}
7 changes: 0 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fd78151

Please sign in to comment.