Skip to content

Commit a2bc20b

Browse files
committed
feat(builder): update template for new build process
1 parent 6440412 commit a2bc20b

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

apps/create-plugin/src/builder.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ async function replaceProjectName(params: BuilderParams) {
175175
const indexTemplate = Handlebars.compile(index)
176176
await fs.writeFile(indexPath, indexTemplate(params))
177177
console.log(`\t ${arrow} Updated file ${cyan('index.ts')}!`)
178+
179+
//replace the project name in the vite config
180+
const vitePath = path.join(dest, 'vite.config.js')
181+
const vite = await fs.readFile(vitePath, 'utf8')
182+
const viteTemplate = Handlebars.compile(vite)
183+
await fs.writeFile(vitePath, viteTemplate(params))
184+
console.log(`\t ${arrow} Updated file ${cyan('vite.config.js')}!`)
178185
}
179186

180187
/**

apps/create-plugin/template/package.json

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,21 @@
22
"name": "@rabbitholegg/questdk-plugin-template",
33
"private": true,
44
"version": "1.0.0-alpha.13",
5+
"description": "",
56
"exports": {
67
"require": "./dist/cjs/index.js",
78
"import": "./dist/esm/index.js",
89
"types": "./dist/types/index.d.ts"
910
},
1011
"main": "./dist/cjs/index.js",
1112
"module": "./dist/esm/index.js",
12-
"description": "",
13+
"types": "./dist/types/index.d.ts",
14+
"typings": "./dist/types/index.d.ts",
1315
"scripts": {
16+
"build": "vite build && tsc --project tsconfig.build.json --emitDeclarationOnly --declaration --declarationMap --declarationDir ./dist/types",
1417
"bench": "vitest bench",
1518
"bench:ci": "CI=true vitest bench",
16-
"build": "pnpm build:types && pnpm build:esm && pnpm postbuild:esm && pnpm build:cjs && pnpm postbuild:cjs && BABEL_ENV=esmBundled pnpm rollup -c",
17-
"build:esm": "BABEL_ENV=esmUnbundled babel src --extensions '.ts' --out-dir 'dist/esm' --source-maps",
18-
"build:cjs": "BABEL_ENV=cjs babel src --extensions '.ts' --out-dir 'dist/cjs' --source-maps",
19-
"build:types": "tsc --project tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
2019
"clean": "rimraf dist",
21-
"postbuild:cjs": "echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
22-
"postbuild:esm": "echo '{\"type\":\"module\"}' > dist/esm/package.json",
2320
"format": "rome format . --write",
2421
"lint": "eslint .",
2522
"lint:fix": "eslint . --fix",
@@ -31,8 +28,6 @@
3128
"keywords": [],
3229
"author": "",
3330
"license": "ISC",
34-
"types": "./dist/types/index.d.ts",
35-
"typings": "./dist/types/index.d.ts",
3631
"devDependencies": {},
3732
"dependencies": {
3833
"@rabbitholegg/questdk-plugin-utils": "workspace:*",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/** @type {import('vite').UserConfig} */
2+
export default {
3+
build: {
4+
rollupOptions: {
5+
external: [/@rabbitholegg/],
6+
},
7+
lib: {
8+
entry: 'src/index.ts',
9+
emptyOutDir: false,
10+
name: 'QuestdkPlugin{{capitalize projectName}}',
11+
fileName: (module, name) => {
12+
const outPath = `${module === 'es' ? 'esm' : 'cjs'}/${
13+
name.startsWith('index') ? 'index.js' : name + '/index.js'
14+
}`
15+
return outPath
16+
},
17+
},
18+
},
19+
}

0 commit comments

Comments
 (0)