Skip to content

Commit

Permalink
feat: ajoute path-utility pour résoudre les paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Shamzic committed Jan 16, 2025
1 parent ce9d988 commit cc3caad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
10 changes: 6 additions & 4 deletions iframes/iframes.config.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import path from "path"
import { resolvePath } from "../lib/utils/path-utils.js"
import config from "../backend/config/index.js"
import webpack from "webpack"

const __dirname = new URL(".", import.meta.url).pathname
process.env.BASE_URL = config.baseURL
process.env.IFRAME_TITLE = config.iframeTitle

export default {
mode: "production",
entry: {
"iframe-integration": path.resolve(__dirname, "./iframe-integration.ts"),
"iframe-integration": resolvePath(
import.meta.url,
"./iframe-integration.ts"
),
},
output: {
path: path.resolve(__dirname, "../public/documents"),
path: resolvePath(import.meta.url, "../public/documents"),
filename: "[name].js",
},
plugins: [new webpack.EnvironmentPlugin(["BASE_URL", "IFRAME_TITLE"])],
Expand Down
9 changes: 9 additions & 0 deletions lib/utils/path-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { fileURLToPath } from "url"
import path from "path"

export function resolvePath(importMetaUrl: string, ...paths: string[]) {
const dirname = path.dirname(fileURLToPath(importMetaUrl))
return path.resolve(dirname, ...paths)
}

export { path }
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"types": ["jest", "cypress", "cypress-axe"],
"types": ["node", "jest", "cypress", "cypress-axe"],
"paths": {
"@/*": ["src/*"],
"@lib/*": ["lib/*"],
Expand Down

0 comments on commit cc3caad

Please sign in to comment.