Skip to content

Commit b58c743

Browse files
committed
updated the vite build process
1 parent b306d8d commit b58c743

File tree

4 files changed

+20
-39
lines changed

4 files changed

+20
-39
lines changed

lib/bin_build/bin-vite.config.mjs

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,19 @@
44
// Utilities
55
import { defineConfig } from 'vite'
66
import { fileURLToPath, URL } from 'node:url'
7+
import {rootFileUrl, viteBaseConfig} from "##/vite.config.mjs";
78
// import { resolve } from 'node:path'
89
// https://vitejs.dev/config/
910
export default defineConfig({
10-
define: { 'process.env': {} },
11-
resolve: {
12-
alias: {
13-
// https://vitejs.dev/config/shared-options.html#resolve-alias
14-
//https://nodejs.dev/en/api/v18/packages/#subpath-imports
15-
'##': fileURLToPath(new URL('./',import.meta.url)),//might want to try # or @ again
16-
'#src': fileURLToPath(new URL('./src', import.meta.url)),
17-
'#docs': fileURLToPath(new URL('./docs', import.meta.url)),//not sure if vite also needs this but yea
18-
},
19-
extensions: [
20-
'.js',
21-
'.json',
22-
'.mjs',
23-
'.vue',
24-
],
25-
},
26-
/**
27-
* For experimentation of puppeteer
28-
*/
11+
...viteBaseConfig,
2912
build: {
30-
//https://vitejs.dev/guide/build.html#library-mode
31-
outDir: fileURLToPath(new URL('./lib/dist/', import.meta.url)),
13+
//https://vitejs.dev/guide/build.html#library-mode
14+
outDir: fileURLToPath(new URL('./lib/bin_build/.output/', rootFileUrl)),
3215
lib: {
3316
name: 'nuxt3-win32-posix-path',
34-
// formats: ['es', 'cjs','umd'],//('es' | 'cjs' | 'umd' | 'iife')
3517
formats: ['es', 'cjs'],//('es' | 'cjs' | 'umd' | 'iife')
36-
//i lost my jsdocs though... weird
3718
entry: [ //"entry" can be a dictionary or array of multiple entry points
38-
// fileURLToPath(new URL('./src/index.mjs', import.meta.url)),
39-
fileURLToPath(new URL('./src/win32ToWin32WSL/win32ToWin32WSL2.mjs', import.meta.url)),
40-
// fileURLToPath(new URL('./temp/toWsl.mjs', import.meta.url)),
41-
// fileURLToPath(new URL('./src/cli/index.mjs', import.meta.url)),
42-
// fileURLToPath(new URL('./dev/node-fs-utils-dev/create-dummy-files.mjs
43-
// ', import.meta.url)),
44-
// fileURLToPath(new URL('./src/win32ToWin32WSL2.mjs', import.meta.url)),
45-
// fileURLToPath(new URL('./src/import-material-theme-pup.mjs', import.meta.url)),
46-
// resolve('src/import-theme-chrome-pup.mjs'),
47-
// Ok... cannot use vite to roll it up... just doesnt work
48-
// resolve('##/src/generate-pupp-json/generate-pupp-json.mjs'),//fixme, this path didnt work?
49-
// fileURLToPath(new URL('./src/generate-pupp-json/generate-pupp-json.mjs', import.meta.url)),
50-
// resolve('##/src/index.mjs'),
19+
fileURLToPath(new URL('./lib/bin_build/index.mjs', rootFileUrl)),
5120
]
5221
},
5322
rollupOptions: {

lib/bin_build/index.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Bin Build Index Packager
3+
* maybe add cli builder / handler here
4+
*/
5+
import Win32ToWin32WSL2 from "##/src/win32ToWin32WSL/win32ToWin32WSL2.mjs";
6+
export {Win32ToWin32WSL2}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"docs:build": "vitepress build docs",
1717
"docs:preview": "vitepress preview docs",
1818
"build-rollup:vite": "vite build --mode production",
19-
"build-rollup:pkg": "pkg lib/dist/index.js --out-path lib/dist/bins"
19+
"build-rollup:pkg": "pkg lib/dist/index.js --out-path lib/dist/bins",
20+
"build-bins:rollup": "vite build --mode production --config lib/bin_build/bin-vite.config.mjs",
21+
"build-bins:pkg": "pkg lib/bin_build/.output/index.js --out-path lib/bin_build/dist/"
2022
},
2123
"devDependencies": {
2224
"gh-pages": "^4.0.0",

vite.config.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import { fileURLToPath, URL } from 'node:url'
1313
/**
1414
* @type {UserConfigExport}
1515
*/
16-
export const viteBaseConfig = {
16+
export const viteBaseConfig = (()=>{
17+
return {
1718
define: { 'process.env': {} },
1819
resolve: {
1920
alias: {
@@ -71,5 +72,8 @@ export const viteBaseConfig = {
7172
},
7273
},
7374

74-
}
75+
}})();
76+
export const rootFilePath = fileURLToPath(new URL('./', import.meta.url));
77+
/** @type {string|URL} */
78+
export const rootFileUrl = import.meta.url;
7579
export default defineConfig(viteBaseConfig)

0 commit comments

Comments
 (0)