Skip to content

Commit

Permalink
FEATURE: Add setting to include additional paths for css import path …
Browse files Browse the repository at this point in the history
…rewrite
  • Loading branch information
c4ll-m3-j4ck committed Oct 10, 2023
1 parent 75fd507 commit c2d0272
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ sassOptions: null
postcssOptions:
tailwindcss:
config: './tailwind.config.js'
additionalPackagePathPrefixes: []

esbuild:
# Set Neos Flow settings as FLOW variable. If `true` all the settings are passed.
Expand Down
13 changes: 9 additions & 4 deletions postcss.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from "path";
import { fs, chokidar, readCache, bold, dim, cyan, magenta } from "carbon-pipeline";
import { config } from './Lib/helper.mjs'
import postcss from "postcss";
import {
styleFiles as files,
Expand Down Expand Up @@ -137,6 +138,13 @@ function build() {
}

function css(css, file, time) {
const { postcssOptions: { additionalPackagePathPrefixes } = [] } = config;
const combinedPaths = Array.isArray(additionalPackagePathPrefixes) ? additionalPackagePathPrefixes.map(e => {
return `${e}/`
}).join('|') : '';

const regexPattern = new RegExp(`(/_Resources/Static/Packages/)(?:${combinedPaths})?([\\w]+.[\\w]+/)Resources/Public/`, 'g');

return rc()
.then((ctx) => {
return postcss(ctx.plugins)
Expand All @@ -155,10 +163,7 @@ function css(css, file, time) {
.then((result) => {
const tasks = [];
// This fixes url done with resolve()
result.css = result.css.replace(
/(\/_Resources\/Static\/Packages\/[\w]+\.[\w]+\/)Resources\/Public\//g,
"$1"
);
result.css = result.css.replace(regexPattern,"$1$2");

const cssFilesize = humanFileSize(result.css.length);
let mapFilesize = 0;
Expand Down

0 comments on commit c2d0272

Please sign in to comment.