esm-styles 0.2.8 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/lib/build.js +19 -4
  2. package/package.json +1 -1
package/dist/lib/build.js CHANGED
@@ -177,9 +177,15 @@ export async function build(configPath = 'esm-styles.config.js') {
177
177
  // Track output files for each floor
178
178
  const floorFiles = [];
179
179
  for (const floor of floors) {
180
- const { source, layer } = floor;
180
+ const { source, layer, outputPath: floorOutputPath } = floor;
181
181
  const inputFile = path.join(sourcePath, `${source}${suffix}`);
182
- const outputFile = path.join(outputPath, `${source}.css`);
182
+ // Use floor's outputPath if provided, otherwise use default
183
+ const floorOutputDir = floorOutputPath
184
+ ? path.join(basePath, floorOutputPath)
185
+ : outputPath;
186
+ // Ensure the output directory exists
187
+ await fs.mkdir(floorOutputDir, { recursive: true });
188
+ const outputFile = path.join(floorOutputDir, `${source}.css`);
183
189
  const fileUrl = pathToFileUrl(inputFile).href + `?update=${Date.now()}`;
184
190
  const stylesObj = (await import(fileUrl)).default;
185
191
  const css = getCss(stylesObj, {
@@ -196,8 +202,17 @@ export async function build(configPath = 'esm-styles.config.js') {
196
202
  wrappedCss = `${comment}@layer ${layer} {\n${css}\n}`;
197
203
  }
198
204
  await fs.writeFile(outputFile, wrappedCss, 'utf8');
199
- floorFiles.push({ file: `${source}.css`, layer, source });
200
- cssFiles.push({ floor: source, file: `${source}.css`, layer });
205
+ // Calculate relative path from default output directory for imports
206
+ const relativePath = floorOutputPath
207
+ ? path.relative(outputPath, outputFile)
208
+ : `${source}.css`;
209
+ floorFiles.push({
210
+ file: relativePath,
211
+ layer,
212
+ source,
213
+ outputPath: floorOutputPath,
214
+ });
215
+ cssFiles.push({ floor: source, file: relativePath, layer });
201
216
  }
202
217
  // 5. Create main CSS file
203
218
  const mainCssPath = path.join(outputPath, mainCssFile);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esm-styles",
3
- "version": "0.2.8",
3
+ "version": "0.3.0",
4
4
  "description": "A library for working with ESM styles",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",