Skip to content

Commit

Permalink
Merge pull request #429 from rabbitholegg/mmackz/update-template
Browse files Browse the repository at this point in the history
feat(create-plugin): update package.json template
  • Loading branch information
mmackz authored Jul 2, 2024
2 parents 82c29a9 + 6e6b325 commit 7e93a17
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/fair-pens-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rabbitholegg/create-plugin": minor
---

update template for new build process
7 changes: 7 additions & 0 deletions apps/create-plugin/src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ async function replaceProjectName(params: BuilderParams) {
const indexTemplate = Handlebars.compile(index)
await fs.writeFile(indexPath, indexTemplate(params))
console.log(`\t ${arrow} Updated file ${cyan('index.ts')}!`)

//replace the project name in the vite config
const vitePath = path.join(dest, 'vite.config.js')
const vite = await fs.readFile(vitePath, 'utf8')
const viteTemplate = Handlebars.compile(vite)
await fs.writeFile(vitePath, viteTemplate(params))
console.log(`\t ${arrow} Updated file ${cyan('vite.config.js')}!`)
}

/**
Expand Down
13 changes: 4 additions & 9 deletions apps/create-plugin/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,21 @@
"name": "@rabbitholegg/questdk-plugin-template",
"private": true,
"version": "1.0.0-alpha.13",
"description": "",
"exports": {
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts"
},
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"description": "",
"types": "./dist/types/index.d.ts",
"typings": "./dist/types/index.d.ts",
"scripts": {
"build": "vite build && tsc --project tsconfig.build.json --emitDeclarationOnly --declaration --declarationMap --declarationDir ./dist/types",
"bench": "vitest bench",
"bench:ci": "CI=true vitest bench",
"build": "pnpm build:types && pnpm build:esm && pnpm postbuild:esm && pnpm build:cjs && pnpm postbuild:cjs && BABEL_ENV=esmBundled pnpm rollup -c",
"build:esm": "BABEL_ENV=esmUnbundled babel src --extensions '.ts' --out-dir 'dist/esm' --source-maps",
"build:cjs": "BABEL_ENV=cjs babel src --extensions '.ts' --out-dir 'dist/cjs' --source-maps",
"build:types": "tsc --project tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
"clean": "rimraf dist",
"postbuild:cjs": "echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
"postbuild:esm": "echo '{\"type\":\"module\"}' > dist/esm/package.json",
"format": "rome format . --write",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
Expand All @@ -31,8 +28,6 @@
"keywords": [],
"author": "",
"license": "ISC",
"types": "./dist/types/index.d.ts",
"typings": "./dist/types/index.d.ts",
"devDependencies": {},
"dependencies": {
"@rabbitholegg/questdk-plugin-utils": "workspace:*",
Expand Down
19 changes: 19 additions & 0 deletions apps/create-plugin/template/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** @type {import('vite').UserConfig} */
export default {
build: {
rollupOptions: {
external: [/@rabbitholegg/],
},
lib: {
entry: 'src/index.ts',
emptyOutDir: false,
name: 'QuestdkPlugin{{capitalize projectName}}',
fileName: (module, name) => {
const outPath = `${module === 'es' ? 'esm' : 'cjs'}/${
name.startsWith('index') ? 'index.js' : name + '/index.js'
}`
return outPath
},
},
},
}

0 comments on commit 7e93a17

Please sign in to comment.