-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
88 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export const pkgName = PKG_NAME; | ||
export const pkgVersion = PKG_VERSION; | ||
export const pkgName = process.env.PKG_NAME; | ||
export const pkgVersion = process.env.PKG_VERSION; | ||
export const officialLink = 'https://github.com/FrontEndDev-org/unplugin-react-pages'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,25 @@ | ||
/** | ||
* env.d.ts | ||
* @ref https://nodejs.org/api/process.html#processenv | ||
*/ | ||
|
||
namespace NodeJS { | ||
interface ProcessEnv { | ||
/** | ||
* @see https://nodejs.org/api/process.html#processenv | ||
*/ | ||
NODE_ENV: 'development' | 'production' | 'test'; | ||
readonly NODE_ENV: 'development' | 'production' | 'test'; | ||
|
||
/** | ||
* package name | ||
* defined in vite.config.mts | ||
*/ | ||
readonly PKG_NAME: string; | ||
|
||
/** | ||
* package version | ||
* defined in vite.config.mts | ||
*/ | ||
readonly PKG_VERSION: string; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
declare global { | ||
/** | ||
* package name | ||
* defined in vite.config.mts | ||
*/ | ||
export const PKG_NAME: string; | ||
/** | ||
* globals.d.ts | ||
*/ | ||
|
||
/** | ||
* package version | ||
* defined in vite.config.mts | ||
*/ | ||
export const PKG_VERSION: string; | ||
declare global { | ||
// | ||
} | ||
|
||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { pkgName, pkgVersion } from '../src'; | ||
|
||
it('pkg', () => { | ||
expect(pkgName).toEqual(PKG_NAME); | ||
expect(pkgVersion).toEqual(PKG_VERSION); | ||
expect(pkgName).toEqual(process.env.PKG_NAME); | ||
expect(pkgVersion).toEqual(process.env.PKG_VERSION); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,71 @@ | ||
import { externalizeDeps } from 'vite-plugin-externalize-deps'; | ||
import dts from 'vite-plugin-dts'; | ||
import { defineConfig } from 'vitest/config'; | ||
import pkg from './package.json'; | ||
|
||
/** | ||
* vite config | ||
* @file vite.config.mts | ||
* @ref https://vitejs.dev/ | ||
* vitest config | ||
* @ref https://vitest.dev/ | ||
*/ | ||
export default defineConfig((config) => { | ||
return { | ||
plugins: [ | ||
externalizeDeps({ | ||
deps: true, | ||
devDeps: true, | ||
peerDeps: true, | ||
optionalDeps: true, | ||
nodeBuiltins: true, | ||
}), | ||
dts({ | ||
include: 'src', | ||
}), | ||
], | ||
define: { | ||
PKG_NAME: JSON.stringify(config.mode === 'test' ? 'pkg-name-for-test' : pkg.name), | ||
PKG_VERSION: JSON.stringify(config.mode === 'test' ? 'pkg-version-for-test' : pkg.version), | ||
|
||
import { externalizeDeps } from 'vite-plugin-externalize-deps'; | ||
import dts from 'vite-plugin-dts'; | ||
import { defineConfig } from 'vitest/config'; | ||
import pkg from './package.json'; | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
externalizeDeps({ | ||
deps: true, | ||
devDeps: true, | ||
peerDeps: true, | ||
optionalDeps: true, | ||
nodeBuiltins: true, | ||
}), | ||
dts({ | ||
include: 'src', | ||
}), | ||
], | ||
define: { | ||
['process.env.PKG_NAME']: JSON.stringify(pkg.name), | ||
['process.env.PKG_VERSION']: JSON.stringify(pkg.version), | ||
}, | ||
build: { | ||
minify: false, | ||
sourcemap: true, | ||
copyPublicDir: false, | ||
reportCompressedSize: false, | ||
lib: { | ||
entry: { | ||
index: 'src/index.ts', | ||
}, | ||
}, | ||
build: { | ||
minify: false, | ||
sourcemap: true, | ||
copyPublicDir: false, | ||
reportCompressedSize: false, | ||
lib: { | ||
entry: { | ||
index: 'src/index.ts', | ||
rollupOptions: { | ||
output: [ | ||
{ | ||
format: 'esm', | ||
entryFileNames: '[name].mjs', | ||
chunkFileNames: '[name].mjs', | ||
}, | ||
}, | ||
rollupOptions: { | ||
output: [ | ||
{ | ||
format: 'esm', | ||
entryFileNames: '[name].mjs', | ||
chunkFileNames: '[name].mjs', | ||
}, | ||
{ | ||
format: 'cjs', | ||
entryFileNames: '[name].cjs', | ||
chunkFileNames: '[name].cjs', | ||
}, | ||
], | ||
}, | ||
{ | ||
format: 'cjs', | ||
entryFileNames: '[name].cjs', | ||
chunkFileNames: '[name].cjs', | ||
}, | ||
], | ||
}, | ||
// optimizeDeps: { | ||
// exclude: ['fsevents'], | ||
// }, | ||
test: { | ||
globals: true, | ||
coverage: { | ||
all: true, | ||
include: ['src/**/*.ts'], | ||
reporter: ['lcov', 'text'], | ||
}, | ||
}, | ||
// optimizeDeps: { | ||
// exclude: ['fsevents'], | ||
// }, | ||
test: { | ||
globals: true, | ||
env: { | ||
NODE_ENV: 'test', | ||
PKG_NAME: 'pkg-name-for-test', | ||
PKG_VERSION: 'pkg-version-for-test', | ||
}, | ||
coverage: { | ||
all: true, | ||
include: ['src/**/*.ts'], | ||
reporter: ['lcov', 'text'], | ||
}, | ||
}; | ||
}, | ||
}); |