Fork me on GitHub
#clojurescript
<
2024-08-09
roboli00:08:36

I'm trying to use semantic-ui with shadow-cljs and reagent but it seems there is no equivalent for

import 'semantic-ui-css/semantic.min.css'

Sam Ferrell00:08:19

As far as I know shadow-cljs doesn't support importing CSS files into CLJS

Sam Ferrell00:08:14

But do you need to? Isn't it just a CSS file you can import with <link>?

roboli01:08:49

Thanks @U02FVPF04A1, I did that in the end. Just wondering if there was any other solution. The app will be embedded in different sites I wanted to avoid that step.

Sam Ferrell01:08:58

You could always dynamically create the element and append it to the <head> via CLJS alone, no need to change the HTML. Maybe thats what you did!

βœ… 2
roboli01:08:57

Could you elaborate more @U02FVPF04A1 πŸ™

roboli01:08:22

Ah I see, using something like

var sc = document.createElement("script");
sc.setAttribute("src", "");
sc.setAttribute("type", "text/javascript");
document.head.appendChild(sc);

Sam Ferrell01:08:34

If you happen to be using React 19 (unlikely) you can also render a <script> or <link> element directly and React will handle the rest; kinda cool!

πŸ‘€ 2
Roman Liutikov06:08:25

Also for older versions of react there’s react helmet lib that takes care of rendering these tags into head

Vipul Rajan06:08:41

I am trying to create an npm module and I noticed that when you run the release command it does not create a package.json file in the module. Is there a way to do that? So that I can then import it via npm into my react project?

thheller07:08:33

package.json you'll need to generate yourself. just a npm init will get you started and usually its only a small trivial adjustment from there

thheller07:08:20

and the build is generated into the dist folder in that dir

thheller07:08:43

I just run npm publish from that folder and its done

Vipul Rajan07:08:51

Okay. That is actually helpful. I've never delved much into the contents of package.json. I'll have to look for the keyword to include various files.

.
β”œβ”€β”€ app.nodes.test_node.js
β”œβ”€β”€ cljs.core.js
β”œβ”€β”€ cljs_env.js
└── package.json

Vipul Rajan07:08:36

This look about right to you? The files were generated by running shadow-cljs release This is the package.json

{
  "name": "test-module",
  "version": "1.0.0",
  "description": "",
  "main": "app.nodes.test_node.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

thheller07:08:46

node wants paths to start with ./ so change "main": "./app.nodes.test_node.js",

thheller07:08:59

and I personally prefer to have the files in its own dir, makes gitignore cleaner

thheller07:08:33

you may need to add dependencies if you have actual npm dependencies in that package

Vipul Rajan07:08:00

This worked. Thanks a lot.

Ryan13:08:38

Hey, I’m trying to test a fork of Malli, and usually don’t stray at all from clojars / etc. I’ve downloaded and built the jar file, where do I put it and how do I reference it in my clojurescript test project? using shadow-cljs/deps, thanks!

p-himik13:08:47

You don't need to do any of that. Just use :local/root in deps.edn if that fork only exists locally and :git/url+`:git/sha` if it's in a Git repo.

πŸ‘ 1