Skip to content

Commit

Permalink
Move app to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
brijeshb42 committed Jul 23, 2024
1 parent 5c3669e commit ebdc8c9
Show file tree
Hide file tree
Showing 13 changed files with 9 additions and 1,153 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"preview": "vite preview"
},
"dependencies": {
"@pigment-css/react": "workspace:^",
"@pigment-css/react": "latest",
"react": "latest",
"react-dom": "latest"
},
"devDependencies": {
"@pigment-css/unplugin": "workspace:^",
"@pigment-css/unplugin": "latest",
"@types/react": "latest",
"@types/react-dom": "latest",
"css-loader": "^7.1.2",
Expand All @@ -24,19 +24,5 @@
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.0.4"
},
"nx": {
"targets": {
"preview": {
"dependsOn": [
"^build"
]
},
"dev": {
"dependsOn": [
"^build"
]
}
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 5 additions & 2 deletions packages/pigment-css-unplugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
transform,
createFileReporter,
} from '@wyw-in-js/transform';
import { asyncResolveFallback } from '@wyw-in-js/shared';
import { asyncResolveFallback, slugify } from '@wyw-in-js/shared';
import {
UnpluginFactoryOutput,
WebpackPluginInstance,
Expand Down Expand Up @@ -325,11 +325,14 @@ export const plugin = createUnplugin<PigmentOptions, true>((options) => {
}

const rootPath = process.cwd();
const slug = slugify(cssText);
const cssFilename = path
.normalize(`${id.replace(/\.[jt]sx?$/, '')}.pigment.css`)
.normalize(`${id.replace(/\.[jt]sx?$/, '')}-${slug}.pigment.css`)
.replace(/\\/g, path.posix.sep);

const cssRelativePath = path.relative(rootPath, cssFilename).replace(/\\/g, path.posix.sep);
// Starting with null character so that it calls the resolver method (resolveId in line:430)
// Otherwise, webpack tries to resolve the path directly
const cssId = `\0${cssRelativePath}`;

cssFileLookup.set(cssId, cssText);
Expand Down
Loading

0 comments on commit ebdc8c9

Please sign in to comment.