Skip to content

fix(spicetify-creator): add PostCSS config loading support #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/spicetify-creator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spicetify-creator",
"version": "1.0.17",
"version": "1.0.18",
"description": "Easily make Spicetify extensions and custom apps.",
"bin": "./dist/index.js",
"scripts": {
Expand All @@ -17,6 +17,7 @@
"esbuild-plugin-postcss2": "0.1.1",
"glob": "^7.2.0",
"minimist": "^1.2.5",
"postcss-load-config": "^6.0.1",
"uglify-js": "^3.15.1"
},
"files": [
Expand Down
10 changes: 9 additions & 1 deletion packages/spicetify-creator/src/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,22 @@ const build = async (watch: boolean, minify: boolean, outDirectory?: string, inD
fs.mkdirSync(outDirectory, { recursive: true });
}

// Load PostCSS config or fallback to autoprefixer
let postCSSPlugins = [autoprefixer];
try {
const postcssrc = require('postcss-load-config');
const { plugins } = await postcssrc({}, path.dirname(inDirectory));
postCSSPlugins = plugins;
} catch {}

const esbuildOptions = {
platform: 'browser',
external: ['react', 'react-dom'],
bundle: true,
globalName: id,
plugins: [
postCssPlugin.default({
plugins: [autoprefixer],
plugins: postCSSPlugins,
modules: {
generateScopedName: `[name]__[local]___[hash:base64:5]_${id}`
},
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,11 @@ less@^4.x:
needle "^3.1.0"
source-map "~0.6.0"

lilconfig@^3.1.1:
version "3.1.3"
resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-3.1.3.tgz#a1bcfd6257f9585bf5ae14ceeebb7b559025e4c4"
integrity sha512-/vlFKAoH5Cgt3Ie+JLhRbwOsCQePABiU3tJ1egGvyQ+33R/vcwM2Zl2QR/LzjsBeItPt3oSVXapn+m4nQDvpzw==

loader-utils@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-3.2.0.tgz#bcecc51a7898bee7473d4bc6b845b23af8304d4f"
Expand Down Expand Up @@ -1156,6 +1161,13 @@ pify@^4.0.1:
resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231"
integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==

postcss-load-config@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-6.0.1.tgz#6fd7dcd8ae89badcf1b2d644489cbabf83aa8096"
integrity sha512-oPtTM4oerL+UXmx+93ytZVN82RrlY/wPUV8IeDxFrzIjXOLF1pN+EmKPLbubvKHT2HC20xXsCAH2Z+CKV6Oz/g==
dependencies:
lilconfig "^3.1.1"

postcss-modules-extract-imports@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz#cda1f047c0ae80c97dbe28c3e76a43b88025741d"
Expand Down