Skip to content

Commit

Permalink
CSS Prefix Added
Browse files Browse the repository at this point in the history
  • Loading branch information
bubundas17 committed Nov 27, 2023
1 parent 20d2498 commit caeb97a
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 7 deletions.
8 changes: 5 additions & 3 deletions assets/css/style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
.s-whmcs {
@tailwind base;
@tailwind components;
@tailwind utilities;
}
3 changes: 2 additions & 1 deletion assets/css/style.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const postcss = require('postcss');
const postcssImport = require('postcss-import');
const postcssNested = require('postcss-nested');
const tailwindcss = require('tailwindcss');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
const fs = require('fs');
const chokidar = require('chokidar');

const inputFile = './assets/css/style.css';
const outputFile = './assets/css/style.min.css';
const templatesFolder = './templates'; // Update with your templates folder path

const plugins = [
postcssImport,
postcssNested,
tailwindcss,
autoprefixer,
cssnano
];

const processCSS = async () => {
try {
const css = fs.readFileSync(inputFile, 'utf8');

const result = await postcss(plugins).process(css, {
from: inputFile,
to: outputFile,
map: { inline: false },
});

fs.writeFileSync(outputFile, result.css);

console.log('CSS build completed successfully.');
} catch (error) {
console.error('Error building CSS:', error);
}
};

// Function to watch for CSS file changes
const watchCSS = () => {
console.log('Watching for CSS file changes...');
chokidar.watch(inputFile).on('change', () => {
console.log('CSS file changed. Rebuilding...');
processCSS();
});
};

// Function to watch for template file changes
const watchTemplates = () => {
console.log('Watching for template file changes...');
chokidar.watch(templatesFolder).on('change', () => {
console.log('Template file changed. Rebuilding CSS...');
processCSS();
});
};

// Start the initial CSS build
processCSS();

// Start watching for changes in watch mode
if (process.argv.includes('--watch')) {
watchCSS();
watchTemplates(); // Add this line to watch templates folder
}
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"module": "index.ts",
"type": "module",
"scripts": {
"build": "tailwindcss -i ./assets/css/style.css -o ./assets/css/style.min.css --minify",
"watch": "tailwindcss -i ./assets/css/style.css -o ./assets/css/style.min.css --watch --minify"
"build": "node build.js",
"watch": "node build.js --watch"
},
"devDependencies": {
"bun-types": "latest"
Expand All @@ -13,6 +13,12 @@
"typescript": "^5.0.0"
},
"dependencies": {
"autoprefixer": "^10.4.16",
"chokidar": "^3.5.3",
"cssnano": "^6.0.1",
"postcss": "^8.4.31",
"postcss-import": "^15.1.0",
"postcss-nested": "^6.0.1",
"tailwindcss": "^3.3.5"
}
}
9 changes: 9 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
plugins: {
'postcss-import': {},
'postcss-nested': {},
'tailwindcss': {},
'autoprefixer': {},
'cssnano': {}
}
};
3 changes: 3 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module.exports = {
content: ["./templates/**/*.{tpl,js}"],
// corePlugins: {
// preflight: false,
// },
theme: {
extend: {},
},
Expand Down
2 changes: 1 addition & 1 deletion templates/client.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<link href="modules/servers/scalewithus/assets/css/style.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" rel="stylesheet">
<div class="text-left bg-white">
<div class="text-left bg-white s-whmcs">
<div class="p-4 bg-gray-300">
<h2 class="font-semibold text-md mb-3">Service Info</h2>
<div class="text-gray-700">
Expand Down

0 comments on commit caeb97a

Please sign in to comment.