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:
winston 2022-06-13 08:48:36 +02:00 committed by GitHub
parent 7df14a72dd
commit e92b4a9312
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 7 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
dist/
node_modules/

15
esbuild.js Normal file
View 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))

View File

@ -1,19 +1,25 @@
{
"name": "@catppuccin/palette",
"version": "0.1.4",
"version": "0.1.5",
"description": "Soothing pastel themes for the high-spirited!",
"main": "index.js",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.mjs",
"exports": {
".": "./index.js",
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.mjs"
},
"./style": "./css/catppuccin.css"
},
"scripts": {
"test": "ava"
"test": "ava",
"build": "node esbuild.js",
"prepublishOnly": "npm run build"
},
"files": [
"css/",
"index.js",
"dist/index.cjs",
"dist/index.mjs",
"index.d.ts"
],
"types": "index.d.ts",
@ -39,6 +45,7 @@
},
"homepage": "https://github.com/catppuccin/palette#readme",
"devDependencies": {
"ava": "^4.2.0"
"ava": "^4.2.0",
"esbuild": "^0.14.42"
}
}