mirror of
https://github.com/LukeHagar/skeleton.git
synced 2025-12-10 12:47:45 +00:00
Fix: Remove .gitignore from package build (#787)
* gitignore is removed from package build * node script for moving generated files * changed file name * dropped console log
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,3 +10,4 @@ coverage
|
|||||||
pnpm-lock.yaml
|
pnpm-lock.yaml
|
||||||
.vscode
|
.vscode
|
||||||
.temp
|
.temp
|
||||||
|
src/lib/tailwind/generated
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
"coverage": "vitest run --coverage",
|
"coverage": "vitest run --coverage",
|
||||||
"prebuild:jss": "postcss src/lib/styles/all.css --dir .temp --base src/lib/styles",
|
"prebuild:jss": "postcss src/lib/styles/all.css --dir .temp --base src/lib/styles",
|
||||||
"build:jss": "prejss-cli .temp/all.css --format commonjs",
|
"build:jss": "prejss-cli .temp/all.css --format commonjs",
|
||||||
"postbuild:jss": "mkdir -p src/lib/tailwind/generated && mv -f .temp/all.js src/lib/tailwind/generated/allComponents.cjs"
|
"postbuild:jss": "node ./scripts/mv-generated-files.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/adapter-auto": "^1.0.0",
|
"@sveltejs/adapter-auto": "^1.0.0",
|
||||||
|
|||||||
16
scripts/mv-generated-files.js
Normal file
16
scripts/mv-generated-files.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
import { renameSync, mkdirSync } from 'fs';
|
||||||
|
|
||||||
|
try {
|
||||||
|
// makes the directory if it doesn't exist
|
||||||
|
mkdirSync('src/lib/tailwind/generated');
|
||||||
|
} catch (e) {
|
||||||
|
// throws if the directory already exists
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// moves generated file to appropriate location
|
||||||
|
renameSync('.temp/all.js', 'src/lib/tailwind/generated/allComponents.cjs');
|
||||||
|
} catch (e) {
|
||||||
|
console.error(`Failed to move file: ${e}`);
|
||||||
|
}
|
||||||
@@ -1,18 +1,17 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import { readFileSync, writeFileSync } from 'fs'
|
import { readFileSync, unlinkSync, writeFileSync } from 'fs';
|
||||||
|
|
||||||
//Put the exports field back into package.json so that monorepos can work again
|
//Put the exports field back into package.json so that monorepos can work again
|
||||||
let packageJson = readFileSync('package.json').toString()
|
let packageJson = readFileSync('package.json').toString();
|
||||||
packageJson = packageJson.slice(0, packageJson.lastIndexOf('}')-1) //strip closing }
|
packageJson = packageJson.slice(0, packageJson.lastIndexOf('}') - 1); //strip closing }
|
||||||
packageJson +=
|
packageJson += `,
|
||||||
`,
|
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/lib/index.ts",
|
".": "./src/lib/index.ts",
|
||||||
"./themes/*": "./src/lib/themes/*",
|
"./themes/*": "./src/lib/themes/*",
|
||||||
"./styles/*": "./src/lib/styles/*",
|
"./styles/*": "./src/lib/styles/*",
|
||||||
"./tailwind/*": "./src/lib/tailwind/*"
|
"./tailwind/*": "./src/lib/tailwind/*"
|
||||||
}
|
}
|
||||||
}`
|
}`;
|
||||||
|
|
||||||
writeFileSync('package.json', packageJson);
|
writeFileSync('package.json', packageJson);
|
||||||
|
unlinkSync('./package/.gitignore'); // delete .gitignore file from built package
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import { del } from "edit-package-json";
|
import { del } from 'edit-package-json';
|
||||||
import { readFileSync, writeFileSync } from 'fs'
|
import { readFileSync, writeFileSync } from 'fs';
|
||||||
|
|
||||||
//We chop out the exports field of ../package.json rather than manipulate the one in ../package/package.json in case there
|
//We chop out the exports field of ../package.json rather than manipulate the one in ../package/package.json in case there
|
||||||
//are changes to the behaviour of 'vite build'. post-build.js will patch it back in so that monorepos work again.
|
//are changes to the behaviour of 'vite build'. post-build.js will patch it back in so that monorepos work again.
|
||||||
writeFileSync('package.json', del(readFileSync('package.json').toString(), 'exports'))
|
writeFileSync('package.json', del(readFileSync('package.json').toString(), 'exports'));
|
||||||
|
|||||||
Reference in New Issue
Block a user