question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to handle css import?

See original GitHub issue

I’m trying to run like this

node - esbuild-register ./script/some.ts

it breaks when hits a .css file

node_modules/emoji-mart/css/emoji-mart.css:1
.emoji-mart,
^

SyntaxError: Unexpected token '.'
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1031:15)
    at Module._compile (node:internal/modules/cjs/loader:1065:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Object.newLoader (app/node_modules/esbuild-register/dist/node.js:2262:9)

is there a way to make it “bundle” css

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Cerberuscommented, Apr 8, 2022

And don’t forget to check this out https://esbuild.github.io/content-types/#css

esbuild-register support loader css too.

register({ extensions: ['.css'], loader: 'css' })
1reaction
Cerberuscommented, Apr 8, 2022

Have you tried to create your own register like this ?

node -r ./esbuild-register.js ...
// ./esbuild-register.js
const { register } = require('esbuild-register/dist/node')

register({ extensions: ['.js', '.ts'] })

register({
  extensions: ['.css'],
  loader: 'file', // may be 'text' (depend on use-case)
})

However, this works for global style sheet (not CSS module).

Read more comments on GitHub >

github_iconTop Results From Across the Web

import - CSS: Cascading Style Sheets - MDN Web Docs
The @import CSS at-rule is used to import style rules from other valid stylesheets. An @import rule must be defined at the top...
Read more >
CSS @import Rule - W3Schools
The @import rule allows you to import a style sheet into another style sheet. The @import rule must be at the top of...
Read more >
Best way to include CSS? Why use @import? - Stack Overflow
In that one case the parent CSS file has to be downloaded first, complete its CSS parsing and download first, discover the @imports,...
Read more >
CSS Import - KeyCDN
It describes how the elements should be rendered on screen. This is where the CSS @import at-rule steps in to help. The @import...
Read more >
How to include one CSS file in another? - GeeksforGeeks
Note: There are two different ways to import a CSS file into another using @import url(“style2.css”); or @import “style2.css”; or directly ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found