mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-05 03:25:10 +08:00
48 lines
985 B
JavaScript
48 lines
985 B
JavaScript
const { join } = require('node:path');
|
|
|
|
const cssnano = require('cssnano');
|
|
const tailwindcss = require('tailwindcss');
|
|
const autoprefixer = require('autoprefixer');
|
|
|
|
const { getCwdFromDistribution } = require('../config/cwd.cjs');
|
|
|
|
const projectCwd = getCwdFromDistribution(process.env.DISTRIBUTION);
|
|
|
|
const twConfig = (function () {
|
|
try {
|
|
const config = require(`${projectCwd}/tailwind.config.js`);
|
|
const { content } = config;
|
|
if (Array.isArray(content)) {
|
|
config.content = content.map(c =>
|
|
c.startsWith(projectCwd) ? c : join(projectCwd, c)
|
|
);
|
|
}
|
|
return config;
|
|
} catch {
|
|
return null;
|
|
}
|
|
})();
|
|
|
|
module.exports = function (context) {
|
|
const plugins = [
|
|
cssnano({
|
|
preset: [
|
|
'default',
|
|
{
|
|
convertValues: false,
|
|
},
|
|
],
|
|
}),
|
|
];
|
|
|
|
if (twConfig) {
|
|
plugins.push(tailwindcss(twConfig), autoprefixer());
|
|
}
|
|
|
|
return {
|
|
from: context.from,
|
|
plugins,
|
|
to: context.to,
|
|
};
|
|
};
|