Skip to content
代码片段 群组 项目
提交 46886599 编辑于 作者: Lukas Eipert's avatar Lukas Eipert
浏览文件

Ensure css_in_js file is created during dev

Once the vite server starts, we compile tailwind_all_the_way once in
order to generate the css_in_js file.

I cannot wait that we get rid of that file...
上级 e1449841
No related branches found
No related tags found
1 合并请求!2419Fix TanukiBot spec relying on outdated code
/* eslint-disable import/extensions */
import { exec as execCB } from 'node:child_process';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import util from 'node:util';
import { createProcessor } from 'tailwindcss/lib/cli/build/plugin.js';
const exec = util.promisify(execCB);
// Note, in node > 21.2 we could replace the below with import.meta.dirname
const ROOT_PATH = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../');
......@@ -45,11 +49,27 @@ function wasScriptCalledDirectly() {
return process.argv[1] === fileURLToPath(import.meta.url);
}
async function ensureCSSinJS() {
const cmd = 'yarn run pretailwindcss:build';
console.log('Ensuring config/helpers/tailwind/css_in_js.js exists');
const { stdout, error } = await exec(cmd, {
env: { ...process.env, REDIRECT_TO_STDOUT: 'true' },
});
if (error) {
throw error;
}
console.log(`'${cmd}' printed:`);
console.log(`${stdout}`);
}
export function viteTailwindCompilerPlugin({ shouldWatch = true }) {
return {
name: 'gitlab-tailwind-compiler',
async configureServer() {
build({ shouldWatch });
await ensureCSSinJS();
return build({ shouldWatch });
},
};
}
......@@ -57,7 +77,8 @@ export function viteTailwindCompilerPlugin({ shouldWatch = true }) {
export function webpackTailwindCompilerPlugin({ shouldWatch = true }) {
return {
async start() {
build({ shouldWatch });
await ensureCSSinJS();
return build({ shouldWatch });
},
};
}
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册