Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(editor): remove css injected by js plugin #4234

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"require": "./dist/editor.js",
"types": "./dist/index.d.ts"
},
"./style.css": "./dist/style.css"
"./dist/style.css": "./dist/style.css"
},
"main": "./dist/editor.js",
"module": "./dist/editor.js",
Expand Down Expand Up @@ -128,7 +128,6 @@
"typescript": "^5.4.5",
"uuid": "^9.0.1",
"vite": "^5.4.8",
"vite-plugin-css-injected-by-js": "^3.5.1",
"vite-plugin-dts": "3.8.3",
"vite-plugin-svgr": "^4.2.0"
},
Expand Down
3 changes: 1 addition & 2 deletions packages/editor/src/tailwind/components.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@
@apply z-[101];
}
.serlo-table {
@apply mx-side border-separate border-spacing-0 hyphens-auto whitespace-nowrap break-normal border-brand-200;
/* TODO: mobile:whitespace-normal */
@apply mx-side border-separate border-spacing-0 hyphens-auto whitespace-nowrap break-normal border-brand-200 sm:whitespace-normal;
}
.serlo-th {
@apply border-b-3 border-r-3 border-brand-200 bg-brand-100 p-1.5 pl-3 text-left;
Expand Down
22 changes: 0 additions & 22 deletions packages/editor/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
import svgr from 'vite-plugin-svgr'
import replace from '@rollup/plugin-replace'
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
import { existsSync, mkdirSync, writeFileSync } from 'fs'

// https://vitejs.dev/guide/build.html#library-mode

Expand Down Expand Up @@ -78,25 +76,5 @@ export default defineConfig({
rollupTypes: true,
}),
svgr({ include: '**/*.svg' }),
cssInjectedByJsPlugin({
// Tried using the injectCodeFunction, but it didn't get called.
// preRenderCSSCode works!
preRenderCSSCode: (cssCode) => {
try {
// Ensure the dist directory exists
const distDir = resolve(__dirname, 'dist')
if (!existsSync(distDir)) {
mkdirSync(distDir, { recursive: true })
}

// Write the CSS to a file. Usually, this plugin excludes css bundles
// from the output but we need to export it for the shadow DOM
writeFileSync(resolve(__dirname, 'dist', 'style.css'), cssCode)
} catch (e) {
console.error('Failed to write CSS to file', e)
}
return cssCode
},
}),
],
})
1 change: 0 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5744,7 +5744,6 @@ __metadata:
typescript: ^5.4.5
uuid: ^9.0.1
vite: ^5.4.8
vite-plugin-css-injected-by-js: ^3.5.1
vite-plugin-dts: 3.8.3
vite-plugin-svgr: ^4.2.0
languageName: unknown
Expand Down