Skip to content
This repository was archived by the owner on Apr 19, 2021. It is now read-only.

Commit 810c7a2

Browse files
committed
🌊 upstream: all the stuff just done in sapper-postcss-template and sapper-typescript-graphql-template that hasn't made its way here yet
1 parent 9943da6 commit 810c7a2

13 files changed

+1117
-1026
lines changed

‎.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ firebase-debug.log
66
/node_modules/
77
__sapper__/
88
/src/node_modules/@sapper/
9+
/static/global.css
10+
/static/global.css.map

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ The [Apple touch icon](https://developer.apple.com/library/archive/documentation
116116
### 🗺 Source maps
117117
This project base comes with [source maps](https://blog.teamtreehouse.com/introduction-source-maps) enabled during development and disabled during production for the best compromise between performance and developer experience. You can change this behavior through the `sourcemap` variable in `rollup.config.js`.
118118

119-
### 💨 Optionally removing Tailwind CSS
119+
### 💨 Optionally removing Tailwind CSS (and PurgeCSS)
120120

121121
1. Remove all Tailwind imports in the `src/global.pcss` file
122122
2. Remove these lines in `postcss.config.js`:

‎build-global-css.mjs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import fs from "fs";
2+
import postcss from "postcss";
3+
// eslint-disable-next-line import/extensions
4+
import postcssConfig from "./postcss.config.js";
5+
6+
const { readFile, unlink, writeFile } = fs.promises;
7+
8+
const main = async () => {
9+
let sourcemap = process.argv[process.argv.length - 1];
10+
if (sourcemap === "true") sourcemap = true;
11+
else if (sourcemap === "false") sourcemap = false;
12+
13+
const pcss = await readFile("src/global.pcss");
14+
15+
const result = await postcss(postcssConfig.plugins).process(pcss, { from: "src/global.pcss", to: "static/global.css", map: sourcemap ? { inline: sourcemap === "inline" } : false });
16+
17+
await writeFile("static/global.css", result.css);
18+
19+
if (result.map) await writeFile("static/global.css.map", result.map.toString());
20+
else {
21+
try {
22+
await unlink("static/global.css.map");
23+
} catch (err) {
24+
if (err.code !== "ENOENT") {
25+
throw err;
26+
}
27+
}
28+
}
29+
};
30+
31+
main();

0 commit comments

Comments
 (0)