Skip to content

Commit

Permalink
Added custom function into tailwind to fetch content from core folder
Browse files Browse the repository at this point in the history
Signed-off-by: Trey <[email protected]>
  • Loading branch information
TreyWW committed Dec 27, 2024
1 parent ffeb8f1 commit 5b20a74
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
/** @type {import('tailwindcss').Config} */

const {execSync} = require('child_process');

function getDjangoTemplatesPath(appName, packageName = appName) {
try {
// Use Python to dynamically resolve the app's templates path
const result = execSync(
`python -c "import importlib.util, os; app_path = importlib.util.find_spec('${packageName}').origin; print(os.path.join(os.path.dirname(app_path), 'templates'))"`
).toString().trim();
return result;
} catch (error) {
console.error(`Could not resolve templates path for ${packageName}:`, error);
return null;
}
}

const externalAppTemplates = getDjangoTemplatesPath('core', 'strelix-core');

console.log(externalAppTemplates)

module.exports = {
mode: 'jit',
content: [
Expand All @@ -8,7 +28,8 @@ module.exports = {
'./frontend/templates/base/base.html',
'./backend/**/views/*.py',
'./backend/views/core/**/*.py',
'./assets/scripts/tableify.js'
'./assets/scripts/tableify.js',
externalAppTemplates ? `${externalAppTemplates}/**/*.html` : ''
],
safelist: [
'alert',
Expand Down

0 comments on commit 5b20a74

Please sign in to comment.