Skip to content

Commit

Permalink
better path detection handling
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 committed Oct 8, 2024
1 parent 9670170 commit b71af39
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions packages/plugin-css-modules/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ function getCssModulesMap(compilation) {
const locationUrl = new URL('./__css-modules-map.json', compilation.context.scratchDir);
let cssModulesMap = {};

if (fs.existsSync(locationUrl.pathname)) {
cssModulesMap = JSON.parse(fs.readFileSync(locationUrl.pathname));
if (fs.existsSync(locationUrl)) {
cssModulesMap = JSON.parse(fs.readFileSync(locationUrl));
}

return cssModulesMap;
Expand Down Expand Up @@ -147,12 +147,10 @@ class CssModulesResource extends ResourceInterface {
this.extensions = ['module.css'];
this.contentType = 'text/javascript';

// // console.log('constructor???')
if (!fs.existsSync(this.compilation.context.scratchDir.pathname)) {
// // console.log('!!!!!!!!! make it!');
fs.mkdirSync(this.compilation.context.scratchDir.pathname, { recursive: true });
if (!fs.existsSync(this.compilation.context.scratchDir)) {
fs.mkdirSync(this.compilation.context.scratchDir, { recursive: true });
fs.writeFileSync(
new URL('./__css-modules-map.json', this.compilation.context.scratchDir).pathname,
new URL('./__css-modules-map.json', this.compilation.context.scratchDir),
JSON.stringify({})
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { implementation } from 'jsdom/lib/jsdom/living/nodes/HTMLStyleElement-im
const expect = chai.expect;

describe('Build Greenwood With: ', function() {
const LABEL = 'Default Configuration for CSS Modules with pre-rendering';
const LABEL = 'Default Configuration for CSS Modules';
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
const outputPath = fileURLToPath(new URL('.', import.meta.url));
let runner;
Expand Down

0 comments on commit b71af39

Please sign in to comment.