Skip to content

Commit 043158a

Browse files
chiolthebestluck
andauthored
feat(tailwindcss): add postcss plugins and update configuration for full CSS generation (#203)
* feat(tailwindcss): add postcss plugins and update configuration for full CSS generation * chore: add license information to index.css --------- Co-authored-by: goun-choe <goun.choe@linecorp.com>
1 parent b1e5de6 commit 043158a

File tree

10 files changed

+287
-15
lines changed

10 files changed

+287
-15
lines changed

packages/tailwindcss/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@
4646
"eslint": "catalog:",
4747
"glob": "^11.0.3",
4848
"postcss": "^8.5.6",
49+
"postcss-cli": "^11.0.1",
50+
"postcss-discard-comments": "^7.0.4",
4951
"postcss-import": "^16.1.1",
5052
"postcss-js": "^4.0.1",
53+
"postcss-minify": "^1.2.0",
5154
"postcss-nesting": "^13.0.2",
5255
"prettier": "catalog:",
5356
"stylelint": "catalog:",
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
module.exports = {
2-
plugins: [require('postcss-import'), require('tailwindcss/nesting')],
2+
plugins: [
3+
require("postcss-import"),
4+
require("tailwindcss/nesting"),
5+
require("postcss-minify"),
6+
require("postcss-discard-comments"),
7+
],
38
};

packages/tailwindcss/src/build.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1+
const { exec } = require("node:child_process");
2+
3+
function runCommand(command) {
4+
return new Promise((resolve, reject) => {
5+
exec(command, (error, stdout, stderr) => {
6+
if (error) {
7+
reject(error);
8+
} else {
9+
resolve({ stdout, stderr });
10+
}
11+
});
12+
});
13+
}
14+
115
const generateCss = require("./build-functions/generate-css");
216
const mergeCss = require("./build-functions/merge-css");
317
const convertCssToJs = require("./build-functions/convert-css-to-js");
418
const log = require("./build-functions/log");
519

620
async function executeCommands() {
721
try {
8-
const totalSteps = 9;
22+
const totalSteps = 10;
923
let currentStep = 0;
1024

1125
log.info("Starting CSS build process...");
@@ -43,6 +57,12 @@ async function executeCommands() {
4357
await convertCssToJs("components");
4458
log.success("Components CSS processing completed");
4559

60+
log.step(++currentStep, totalSteps, "Generate full css file");
61+
await runCommand(
62+
"../../node_modules/.bin/postcss src/full/index.css -o dist/full.css --config src/full",
63+
);
64+
log.success("Full CSS file generated successfully");
65+
4666
log.success("All CSS files built successfully!");
4767
} catch (error) {
4868
log.error(`Error executing commands: ${error.message}`);
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
module.exports = {
22
plugins: [
3-
require('postcss-import'),
4-
require('tailwindcss/nesting'),
5-
require('tailwindcss')('./src/components/tailwind.config.js'),
3+
require("postcss-import"),
4+
require("tailwindcss/nesting"),
5+
require("tailwindcss")("./src/components/tailwind.config.js"),
6+
require("postcss-discard-comments"),
7+
require("postcss-minify"),
68
],
79
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Copyright 2025 LY Corporation
3+
*
4+
* LY Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
@import "tailwindcss/base";
17+
@import "tailwindcss/components";
18+
@import "tailwindcss/utilities";
19+
@import "../../dist/base";
20+
@import "../../dist/components";
21+
@import "../../dist/utilities";
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
plugins: [
3+
require("postcss-import"),
4+
require("tailwindcss/nesting"),
5+
require("tailwindcss")("./src/full/tailwind.config.js"),
6+
require("autoprefixer"),
7+
require("postcss-discard-comments"),
8+
require("postcss-minify"),
9+
],
10+
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const plugin = require("tailwindcss/plugin");
2+
const theme = require("../theme");
3+
4+
function filterDefault(values) {
5+
return Object.fromEntries(
6+
Object.entries(values).filter(([key]) => key !== "DEFAULT"),
7+
);
8+
}
9+
10+
/** @type {import('tailwindcss').Config} */
11+
module.exports = {
12+
darkMode: "class",
13+
content: [{ raw: "" }],
14+
safelist: [
15+
{
16+
pattern:
17+
/(fill|text|bg|border|text-above)-neutral-(primary|secondary|tertiary|inverse|disabled|static|hover|transparent|dim)/,
18+
},
19+
{
20+
pattern: /bg-(primary|secondary|tertiary|dim)/,
21+
},
22+
{
23+
pattern: /(fill|text|border)-tint-(red|orange|green|blue)/,
24+
},
25+
{
26+
pattern: /bg-tint-(red|orange|green|blue)-(bold|subtle|hover|)/,
27+
},
28+
{
29+
pattern: /rounded(-|)(0|4|6|8|12|16|24|full|)/,
30+
},
31+
{
32+
pattern: /shadow(-|)(sm|md|lg|xl|2xl|inner|none|)/,
33+
},
34+
],
35+
theme,
36+
plugins: [
37+
plugin(({ addBase, addUtilities, addComponents }) => {
38+
addBase(require("../../dist/base"));
39+
addComponents(require("../../dist/components"));
40+
addUtilities(require("../../dist/utilities"));
41+
}),
42+
],
43+
};
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
module.exports = {
22
plugins: [
3-
require('postcss-import'),
4-
require('tailwindcss/nesting'),
5-
require('tailwindcss')('./src/utilities/tailwind.config.js'),
3+
require("postcss-import"),
4+
require("tailwindcss/nesting"),
5+
require("tailwindcss")("./src/utilities/tailwind.config.js"),
6+
require("postcss-discard-comments"),
7+
require("postcss-minify"),
68
],
79
};

packages/tailwindcss/src/utilities/tailwind.config.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,3 @@ module.exports = {
233233
}),
234234
],
235235
};
236-
237-
// {
238-
// pattern:
239-
// /(bg|text|fill|border|text-above)-neutral-(primary|secondary|tertiary|quaternary|dim|)/,
240-
// },

0 commit comments

Comments
 (0)