feat: npm package: hybrid cjs+esm support (#14)
* feat(npm): add build script for hybrid cjs+esm support * style: fix mixed indents * allow import from CSS * doc: instructions on how to import css file * refactor(npm): use esbuild.js for a single build command * chore: fix mixed indents * fix(npm): rename file extension in npm include list Co-authored-by: sakkke <w32w64@gmail.com> Co-authored-by: Pocco81 <58336662+Pocco81@users.noreply.github.com> Co-authored-by: Pocco81 <pocco451@gmail.com>
This commit is contained in:
parent
7df14a72dd
commit
e92b4a9312
3 changed files with 30 additions and 7 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
|
dist/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
15
esbuild.js
Normal file
15
esbuild.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
const esbuild = require('esbuild');
|
||||||
|
|
||||||
|
const buildCJS = esbuild.build({
|
||||||
|
entryPoints: ['./index.js'],
|
||||||
|
outfile: './dist/index.cjs',
|
||||||
|
format: 'cjs'
|
||||||
|
})
|
||||||
|
|
||||||
|
const buildESM = esbuild.build({
|
||||||
|
entryPoints: ['./index.js'],
|
||||||
|
outfile: './dist/index.mjs',
|
||||||
|
format: 'esm'
|
||||||
|
})
|
||||||
|
|
||||||
|
Promise.all([buildCJS, buildESM]).catch(() => process.exit(1))
|
21
package.json
21
package.json
|
@ -1,19 +1,25 @@
|
||||||
{
|
{
|
||||||
"name": "@catppuccin/palette",
|
"name": "@catppuccin/palette",
|
||||||
"version": "0.1.4",
|
"version": "0.1.5",
|
||||||
"description": "Soothing pastel themes for the high-spirited!",
|
"description": "Soothing pastel themes for the high-spirited!",
|
||||||
"main": "index.js",
|
"main": "dist/index.js",
|
||||||
"type": "module",
|
"module": "dist/index.mjs",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./index.js",
|
".": {
|
||||||
|
"require": "./dist/index.cjs",
|
||||||
|
"import": "./dist/index.mjs"
|
||||||
|
},
|
||||||
"./style": "./css/catppuccin.css"
|
"./style": "./css/catppuccin.css"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "ava"
|
"test": "ava",
|
||||||
|
"build": "node esbuild.js",
|
||||||
|
"prepublishOnly": "npm run build"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"css/",
|
"css/",
|
||||||
"index.js",
|
"dist/index.cjs",
|
||||||
|
"dist/index.mjs",
|
||||||
"index.d.ts"
|
"index.d.ts"
|
||||||
],
|
],
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
|
@ -39,6 +45,7 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/catppuccin/palette#readme",
|
"homepage": "https://github.com/catppuccin/palette#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"ava": "^4.2.0"
|
"ava": "^4.2.0",
|
||||||
|
"esbuild": "^0.14.42"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue