forked from tajo/ladle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: various fixes to make baseweb working (tajo#24)
* fix: various fixes to make baseweb working * fix: use ESM for vite-plugin * fix: meta.json, history, better errors * fix: tests disabled temp, have to fix esm in jest Co-authored-by: tajo <[email protected]>
- Loading branch information
Showing
27 changed files
with
353 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export default { | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
transform: {}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { dirname, join } from "path"; | ||
import { fileURLToPath } from "url"; | ||
import react from "@vitejs/plugin-react"; | ||
import ladlePlugin from "./vite-plugin/vite-plugin.js"; | ||
|
||
/** | ||
* @param ladleConfig {import("../shared/types").Config} | ||
* @param configFolder {string} | ||
* @param viteConfig {import('vite').InlineConfig} | ||
*/ | ||
const getBaseViteConfig = (ladleConfig, configFolder, viteConfig) => { | ||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
/** | ||
* @type {import('vite').InlineConfig} | ||
*/ | ||
const config = { | ||
...viteConfig, | ||
configFile: false, | ||
root: join(__dirname, "../app/"), | ||
base: ladleConfig.build.baseUrl, | ||
plugins: [ | ||
ladlePlugin(ladleConfig, configFolder), | ||
react({ | ||
babel: { | ||
presets: ["@babel/preset-flow", ...ladleConfig.babelPresets], | ||
plugins: ladleConfig.babelPlugins, | ||
}, | ||
}), | ||
...(viteConfig.plugins ? viteConfig.plugins : []), | ||
], | ||
esbuild: { | ||
include: /\.(tsx?|jsx?)$/, | ||
exclude: [], | ||
loader: "tsx", | ||
...(viteConfig.esbuild ? viteConfig.esbuild : {}), | ||
}, | ||
}; | ||
return config; | ||
}; | ||
|
||
export default getBaseViteConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 10 additions & 5 deletions
15
packages/ladle/lib/cli/vite-plugin/generate/get-config-import.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
import fs from "fs"; | ||
import path from "path"; | ||
import { fileURLToPath } from "url"; | ||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
|
||
/** | ||
* @param {string} configFolder | ||
*/ | ||
const getConfigImport = (configFolder) => { | ||
const configPath = path.join(configFolder, "config.mjs"); | ||
const configExists = fs.existsSync(configPath); | ||
const relativePath = "./config.js"; | ||
let configCode = `export let config = {};\n`; | ||
if (configExists) { | ||
configCode += `import customConfig from '${relativePath}';\nconfig = customConfig;\n`; | ||
configCode += `import customConfig from '${path.relative( | ||
path.join(__dirname, "../../../app/src"), | ||
path.join(configFolder, "config.mjs"), | ||
)}';\nconfig = customConfig;\n`; | ||
} | ||
return `${configCode}`; | ||
}; | ||
|
||
module.exports = getConfigImport; | ||
export default getConfigImport; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,4 @@ const getHmr = () => `if (import.meta.hot) { | |
}); | ||
}`; | ||
|
||
module.exports = getHmr; | ||
export default getHmr; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.