Skip to content
Snippets Groups Projects
Commit 50ceed1f authored by andree.klattenhoff's avatar andree.klattenhoff
Browse files

Removed: Code injection to load stylesheets for js files

Changelog:
  - Injection of code to load stylesheets is now required to be resolved during
    the build process of ui projects.
    The plugin vite-plugin-ox-css is available.
parent b3be83ca
No related branches found
No related tags found
No related merge requests found
......@@ -38,13 +38,6 @@ describe('JS files with dependencies contain events', function () {
td.reset()
})
it('javascript file contains dispatcher for dependencies', async function () {
const response = await request(app.server).get('/index.html.js')
expect(response.statusCode).to.equal(200)
expect(response.headers.dependencies).to.equal('main.css')
expect(response.text).to.equal('console.log("this is index.html.js")\n/*injected by ui-middleware*/document.dispatchEvent(new CustomEvent("load-css",{detail:{css:["main.css"]}}))')
})
it('javascript files from different versions have correct dependencies', async function () {
const r1 = await request(app.server).get('/index.html.js')
expect(r1.headers.dependencies).to.equal('main.css')
......
......@@ -21,15 +21,8 @@ export function createWritable (body) {
}
async function createFileBuffer (response, dependencies) {
const cssString = dependencies && dependencies.map(file => `"${file}"`).join(',')
const appendix = cssString && `\n/*injected by ui-middleware*/document.dispatchEvent(new CustomEvent("load-css",{detail:{css:[${cssString}]}}))`
const resBuffer = await response.arrayBuffer()
const appendixLength = appendix?.length || 0
const buffer = Buffer.alloc(resBuffer.byteLength + appendixLength)
buffer.fill(Buffer.from(resBuffer), 0, resBuffer.byteLength)
if (appendix) buffer.write(appendix, resBuffer.byteLength)
const arrayBuffer = await response.arrayBuffer()
const buffer = Buffer.from(arrayBuffer)
return buffer
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment