Skip to content

Commit

Permalink
fix(build): Actually copy css file during build instead of symlinking
Browse files Browse the repository at this point in the history
  • Loading branch information
wise-king-sullyman committed Jul 26, 2024
1 parent c668f18 commit 4045742
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/module/scripts/writeClassMaps.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { join, basename, relative, dirname } = require('path');
const { outputFileSync, copyFileSync, ensureDirSync, symlinkSync } = require('fs-extra');
const { outputFileSync, copyFileSync, ensureDirSync } = require('fs-extra');
const { generateClassMaps } = require('./generateClassMaps');

const writeTsExport = (file, classMap, outDir) =>
Expand All @@ -22,21 +22,21 @@ function writeClassMaps(classMaps) {
// write the export map in TS and put it in src, from here TS will compile it to the different module types at build time
writeTsExport(relativeFilePath, classMap, packageBase);

// copy the css file itself over to dist since TS won't do that
// copy the css file itself over to dist so that they can be easily imported since TS won't do that
const cssFileName = basename(file);
const distDir = join(packageBase, 'dist');
const cssDistDir = join(distDir, 'css');
ensureDirSync(cssDistDir);
copyFileSync(file, join(cssDistDir, cssFileName));

// create symlinks for each exported module that reference to the single copy of the css files, prevents needing duplicates of the stylesheets
// create css files for each exported module to reference since TS won't do that either
const fileDir = dirname(relativeFilePath).replace('src/', '');
const cssDistEsmDir = join(distDir, 'esm', fileDir);
const cssDistCjsDir = join(distDir, 'js', fileDir);
const cssDistDirs = [cssDistEsmDir, cssDistCjsDir];
cssDistDirs.forEach((dir) => {
ensureDirSync(dir);
symlinkSync(join(cssDistDir, cssFileName), join(dir, cssFileName));
copyFileSync(file, join(dir, cssFileName));
});
});

Expand Down

0 comments on commit 4045742

Please sign in to comment.