(nuxt) configure postcss to enable RTL stylings

This commit is contained in:
Valentyne Stigloher 2024-07-18 13:59:42 +02:00
parent 9639d2204e
commit 26688dd7e9

View File

@ -1,10 +1,8 @@
import './src/dotenv.ts';
import { loadSuml } from './server/loader.ts';
import autoprefixer from 'autoprefixer';
import fs from 'fs';
import path from 'path';
import rtlcss from 'rtlcss';
import { defineNuxtConfig } from 'nuxt/config';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import replacePlugin from '@rollup/plugin-replace';
@ -12,7 +10,6 @@ import yamlPlugin from '@rollup/plugin-yaml';
import { sentryVitePlugin } from '@sentry/vite-plugin';
import type { IncomingMessage } from 'connect';
import type { ServerResponse } from 'http';
import type { Plugin as PostcssPlugin } from 'postcss';
import { buildList } from './src/helpers.ts';
import buildLocaleList from './src/buildLocaleList.ts';
import formatError from './src/error.ts';
@ -72,12 +69,13 @@ const esBuildOptions = {
},
};
const postCssPlugins: PostcssPlugin[] = [
autoprefixer(),
];
const postCssPlugins: Record<string, object> = {
autoprefixer: {},
cssnano: {},
};
if (config.dir === 'rtl') {
postCssPlugins.push(rtlcss() as PostcssPlugin);
postCssPlugins.rtlcss = {};
}
const hostname = process.env.HOST ?? '0.0.0.0';
@ -218,12 +216,8 @@ exports.randomFillSync = randomFillSync`],
options: esBuildOptions,
},
},
build: {
postcss: {
postcssOptions: {
plugins: postCssPlugins,
},
},
postcss: {
plugins: postCssPlugins,
},
serverHandlers: [
{