<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Marc on Medium]]></title>
        <description><![CDATA[Stories by Marc on Medium]]></description>
        <link>https://medium.com/@edgedoval?source=rss-9555e451e04------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*2DJnc9RhXUeMdaiKj3_hHw.jpeg</url>
            <title>Stories by Marc on Medium</title>
            <link>https://medium.com/@edgedoval?source=rss-9555e451e04------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 22:41:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@edgedoval/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Leptos can use Tailwind CSS and daisyUI without Node.js]]></title>
            <link>https://medium.com/@edgedoval/leptos-can-use-tailwind-css-and-daisyui-without-node-js-8b174e222c60?source=rss-9555e451e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b174e222c60</guid>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[daisyui]]></category>
            <category><![CDATA[lepto]]></category>
            <category><![CDATA[tailwind-css]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Marc]]></dc:creator>
            <pubDate>Wed, 07 May 2025 01:28:17 GMT</pubDate>
            <atom:updated>2025-05-08T18:07:50.050Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AQKmUbx9obVX08vTVV36aw.png" /></figure><p>Leptos can use Tailwind CSS and daisyUI without Node.js for simple and robust styling. This approach uses thecargo-leptos crate to:</p><ol><li>Downloads the Tailwind CSS 4 executable.</li><li>Automatically calls the Tailwind executable to transform the source CSS file to an output CSS file.</li><li>Add daisyUI to that existing Tailwind CSS transformation pipeline.</li></ol><p>We’ll start by generating a Leptos site, then add Tailwind CSS, and subsequently add daisyUI.</p><ol><li>Assuming cargo-leptos and other build dependencies are installed as per <a href="http://github.com/leptos-rs/start-axum">http://github.com/leptos-rs/start-axum</a>. Create a new project and change to the newly created directory.</li><li>Create a CSS file called tailwind.css in thestyle folder. This file is the source file that will be transformed. The contents need to be correct syntax for Tailwind.</li></ol><pre>/* Sample Tailwind CSS file */<br><br>@import &quot;tailwindcss&quot;;<br><br>@theme {<br>  --deepblue-500: #023047;<br>  --amber-500: #fd8500;<br>  --alabaster-500: #e0e1dd;<br>}<br><br>.bg-deepblue {<br>  background-color: var(--deepblue-500);<br>}<br><br>.bg-amber {<br>  background-color: var(--amber-500);<br>}<br><br>.text-amber {<br>  color: var(--amber-500);<br>}<br><br>.text-alabaster {<br>  color: var(--alabaster-500);<br>}<br><br>@utility container {<br>  padding: 20px;<br>  margin: auto;<br>  max-width: 1280px;<br>}</pre><p>4. The style sheet referenced in the application is configured in the Cargo.toml file’s package.meta.leptossection. The tailwind-input-file key specifies where the generated CSS file will be found. The reference to the Sass file should be removed.</p><pre>[package.metadata.leptos]<br><br># other config info<br>...<br><br># Specify that we&#39;re using tailwind and where the tailwindcss file is found<br>tailwind-input-file = &quot;style/tailwind.css&quot;<br><br># more config info<br>...</pre><p>5. Use Tailwind CSS utility classes in your markup. Below, I added styles to the existing code sample in the src/app.rs .</p><pre>&lt;h1 class=&quot;m-8 text-4xl&quot;&gt;&quot;Welcome to Leptos!&quot;&lt;/h1&gt;<br>&lt;button class=&quot;mx-8 h-auto p-4 border rounded-md  bg-purple-400 hover:bg-purple-700&quot; on:click=on_click&gt;&quot;Click Me: &quot; {count}&lt;/button&gt;</pre><p>6. The LEPTOS_TAILWIND_VERSION environment variable must be set to specify what version of the Tailwind CSS executable should be downloaded, e.g. export LEPTOS_TAILWIND_VERSION=v4.1.5. If not specified, it currently downloads v4.1.4.<br>7. Run cargo leptos watch . Note: it must be in the same environment, i.e. terminal, as step 5, so the LEPTOS_TAILWIND_VERSION env var is set. Visit the URL listed to view the Tailwind CSS styles in use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kb-wwOc70TEGbXNxV16LjA.png" /><figcaption>Sample content with Tailwind CSS styling</figcaption></figure><h3>Using DaisyUI</h3><ol><li>Download the daisyUI standalone JavaScript files, as per <a href="https://daisyui.com/docs/install/standalone/#2-get-daisyui-bundled-js-file">https://daisyui.com/docs/install/standalone/#2/get-daisyui-bundled-js-file</a>, and place them into the style folder. At present, daisyUI is at version 5.0.35.</li><li>In the tailwind.css file, refer to the daisyUI file with a path like reference. Note the ./in the <a href="http://twitter.com/plugin">@plugin</a> command</li></ol><pre>@plugin &quot;./daisyui.js&quot; {<br> themes: light --default, dark --prefersdark, cupcake;<br>}</pre><p>3. Use a daisyUI class, e.g btn btn-primary. Styles were added via the class attribute to the pre-existing sample code.</p><pre>&lt;h1 class=&quot;m-8 text-8xl underline decoration-wavy&quot;&gt;&quot;Welcome to Leptos!&quot;&lt;/h1&gt;<br>&lt;button class=&quot;m-8 btn btn-primary&quot; on:click=on_click&gt;&quot;Click Me: &quot; {count}&lt;/button&gt;</pre><p>4. Run cargo leptos watch . Note: it must be in the same environment where the LEPTOS_TAILWIND_VERSION env var is set. Visit the URL listed to view the daisyUI CSS styles in use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*91jOU19ddfCI1uwhqNKM-w.png" /><figcaption>Sample content with Tailwind CSS and daisyUI styling</figcaption></figure><p>Source code is available at <a href="https://github.com/cramhead/leptos-tailwindcss-daisyui">https://github.com/cramhead/leptos-tailwindcss-daisyui</a></p><p>That’s all, folks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b174e222c60" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Webpack4, ES2015 with Express on Heroku]]></title>
            <link>https://medium.com/@edgedoval/using-webpack4-es2015-with-express-on-heroku-af6121c90c6a?source=rss-9555e451e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/af6121c90c6a</guid>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[webpack4]]></category>
            <category><![CDATA[heroku]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Marc]]></dc:creator>
            <pubDate>Mon, 02 Apr 2018 21:08:26 GMT</pubDate>
            <atom:updated>2018-04-03T16:10:14.845Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8EkKieo4KVJNx1GLblBTdw.png" /></figure><p>Tech is so unrelenting in its progress. I love seeing how we continually go from ideas to new products, application and markets. It’s a lot a work to keep pace, but there are many gains to be had. Some of the big gains on the web are the improvements in JavaScript. Who would have thought that small scripts that popped alert boxes could have come so far. It turns out that the road of progress is not often smooth. I’m continually bumping into some problem or other.</p><p>Today’s problem was deploying my express server to Heroku. I read though the getting started with node docs, referenced below. It looked really easy. Their sample code deployed without a hitch. I figured let’s try it with an existing project. Boom! That was a complete no go. Even the heroku create statement failed. Unfortunately, the docs didn’t really touch on any of the issues I had. Initially, I didn’t find any good solutions on the web, but after I started writing I did find some excellent posts. They are referenced at the end of the post.</p><p><a href="https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction">Getting Started on Heroku with Node.js | Heroku Dev Center</a></p><p>This post takes us from zero to a minimal server that runs locally and is subsequently deployed to Heroku. I’ve broken up the post so that getting the local build is separate from the Heroku deployment. Hopefully, you’ll be able skip the first parts for your own existing projects.</p><p>This posts assume the you have node and yarn installed and are at least a little familiar with using the terminal. You can use npm instead of yarn. They respond to similar flags at this point. I’m using a mac, but Windows users should only require a few small changes. I’ll try to cover what and why I’m doing things so that you can hopefully resolve any problems that you encounter. Also, the entire source code is available on github.com. Take a look via the link below.</p><p><a href="https://github.com/cramhead/express_es2015_webpack">cramhead/express_es2015_webpack</a></p><h3>Structuring the Project</h3><p>The zero we are starting with is an empty folder. In your terminal go to your standard directory for trying things out and make a new folder. I’m going to use express_es2015_webpack, but you can pick whatever name you’d like. So I run the following.</p><p>mkdir express_es2015_webpack; cd $_</p><p>The command makes a folder and changes directory into it. The semicolon marks the end of a statement, just like in JavaScript. The $_ is resolves to the argument of the previous command. So after the folder is created the shell will change directory into that folder.</p><p>To make a default package.json file.</p><p>yarn init -y</p><p>Add the express package. We’ll use express as a nice way to receive and respond to requests.</p><p>yarn add express</p><p>Webpack 4 looks for source files in a default location, i.e. src, and puts the results of compilation into a default location, i.e. dist. I think that’s great. It just makes things simpler when starting. Create the two folders.</p><p>mkdir src dist</p><p>So far we’ve just been making folders and adding references to the project, but we’ll need a place to put our code. Create an index.js file where webpack would look for it.</p><p>touch src/index.js</p><p>As it turns out the naming of the file is quite important. This is a server, so I’d name it server.js and update the main property in the package.json to use server.js as the main entry point. Unfortunately, this doesn’t work. Webpack will search the src folder, but won’t find server.js. However, it does find the file if it’s called index.js or index.json. Bug? Anyway, it’s not that important. Index is fine. As we’re writing JavaScript it makes sense to call it index.js, not index.json.</p><p>We’re going to use babel for the transpilation, luckily enough some clever and generous people made babel and shared it with us.</p><p>yarn add --dev babel-cli babel-preset-env nodemon</p><p>We can control how babel does what it does by a variety of flags, but it’s usually best to use the .babelrc file to provide configuration information.</p><p>touch .babelrc</p><p>In the .babelrc file we need to tell babel what we want done. For this we’ll use a preset. In this case, the preset is called env. The preset includes all the configuration that you need for es2105+ to es5 transpilation. Note, as you’re reading this post at some point in the future, you may have installed babel 7. I’m using babel version 6.26.0. The preset usage will change slightly with babel 7 so check your package.json file to see what version of babel you’re using. You can find out more about this at <a href="https://babeljs.io/env/">https://babeljs.io/env/</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/665d64645a7abebf8efa377b8531b241/href">https://medium.com/media/665d64645a7abebf8efa377b8531b241/href</a></iframe><p>That’s a lot of commands and we haven’t made a stitch of code yet. Let’s add a small sample. I’m not going into much detail on the index.js code as it’s just something to prove that things are working.</p><h3>Using Express</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27459b058e80825ae9b443b7bd6a1269/href">https://medium.com/media/27459b058e80825ae9b443b7bd6a1269/href</a></iframe><p>The index.js is almost as small as you can make it when using express. It imports the express library. Makes a constant that is populated with the passed in port environment variable. If the port environment variable is undefined it will default to 3000. Create a new express application and call it app. We defined a handler for when the server receives a request on the root path, i.e. ‘/’, of our application. The handler will respond with the string “Server says” followed by the current date and time. Finally, the application is set listen on the port defined previously.</p><p>One last thing and we’re ready to start the server.</p><p>In package.json file add a scripts section. The script will start nodemon. It’s program that automatically watches your files for changes and restarts your program if anything changes. In this case it’ll re-transpile your source whenever there is a change and hold the code in memory. Perfect for development. You can run it directly for you node_modules folder.</p><pre>./node_modules/.bin/nodemon src/index.js --exec babel-node</pre><p>Referencing the executable programs from the node_modules folder is really not the best way. The scripts section lets you call scripts via yarn and makes local packages, i.e. the things in your node_modules folder, available.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3378953d57549902540204aa0454628b/href">https://medium.com/media/3378953d57549902540204aa0454628b/href</a></iframe><p>After adding the dev script our command is much shorter.</p><pre>yarn dev</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*FxV9VR9zTF2pU3I0jdQXlg.png" /><figcaption>The app runs locally</figcaption></figure><p>Awesome! We have something running.</p><h3>Webpack</h3><p>The use of babel is great for development but unfortunately, it’s not so good for production. Babel is building the code and storing the output in memory. This means that any restart will need to rebuild the code. In production it’s better to save the transpiled output to a set of files and have node load the pre-built code. Babel is entirely able to output the built files, but I’m thinking a little longer term. I’d like other assets like CSS, SVG and others to be considered. That’s where Webpack comes in.</p><p><a href="https://babeljs.io/docs/usage/cli/">CLI · Babel</a></p><p>Let’s add webpack and webpack’s command line interface our project. We’ll add it as development dependency with the — dev flag so that these dependencies won’t be included in transpiled output.</p><p>yarn add --dev webpack webpack_cli</p><p>Adjust the scripts section of the package.json file to include a new script to run webpack.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/306f40300ed214fe7aba81a8e5d7fc87/href">https://medium.com/media/306f40300ed214fe7aba81a8e5d7fc87/href</a></iframe><p>If we update the scripts section to include the webpack script we can call it from yarn.</p><p>yarn webpack</p><p>Ugh. This gives us a warning and error. What went wrong?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*I5XtKlKMTBCCC8LwXBrxKw.png" /><figcaption>Initial stab with webpack</figcaption></figure><p>From the output, above, we can see that a main.js was created. This is the default name for the output. Also, there are a number of warnings and errors. Let’s deal with the second warning first, as it’s the easiest one. The warning is telling us that we should specify a mode. We can augment our existing webpack script by providing the mode. Change the webpack script to the following.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/23d29504e5307dc1823b4dbdafae1c96/href">https://medium.com/media/23d29504e5307dc1823b4dbdafae1c96/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*NqpYSYQSs-xOr6Xen6qrsg.png" /><figcaption>Mode issue resolved, but still importing node modules</figcaption></figure><p>Great. That resolved the mode warning. Let’s move on to some of the more difficult problems.</p><p>Webpack builds a graphs of all modules referenced starting from one or more entry points. In many ways this is what babel does too, only different. We can see that webpack is trying to bundle a number of node modules. As it turns out it doesn’t need to bundle them. Luckily, the webpack-node-externals plug-in is built specifically to address this.</p><p>yarn add --dev webpack-node-external</p><p>The package defines a function that lists the node-modules that are reference and tells webpack that they will be provided externally to the bundle, so webpack doesn’t need to bundle them. At this point we need to tell webpack to use the plugin. Make a webpack.config.js file at the root of the project.</p><pre>touch webpack.config.js</pre><p>In the webpack.config.js add the following.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c844630c7a877355f39b2e96a7b5fac/href">https://medium.com/media/6c844630c7a877355f39b2e96a7b5fac/href</a></iframe><p>As it turns out the target specification doesn’t do anything at this point, but it’s a bit of future proofing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*uBRIf4apjprqU69RR26xTA.png" /><figcaption>Success building with webpack</figcaption></figure><p>We can run the file directly with node.</p><pre>node dist/main.js</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*q5V9PILQ9UXgLNN3nhCRfA.png" /><figcaption>Running the transpiled output</figcaption></figure><p>Open a browser and visit <a href="http://localhost:3000/">http://localhost:3000</a> and you should see the following.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*Qh9aTOx5q09snn1DmrulJw.png" /><figcaption>The browser output</figcaption></figure><p>Awesome! We’re getting close now.</p><h3>Version Control</h3><p>If you haven’t already it’s a good time to commit your code to git. Create a new repo.</p><pre>git init</pre><p>At this point there are many files in your project. If you don’t believe me looking inside the node_modules folder. You normally should not check in the node_modules folder. It’s wasteful and add a lot of noise to your repo. So create a .gitignore file in the root of your project and paste the following into it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c66b94e48bf8bed46887ff8b9b6e855b/href">https://medium.com/media/c66b94e48bf8bed46887ff8b9b6e855b/href</a></iframe><p>At this point git will ignore about 99.9% of you files, but it will track the ones that are relevant. Something of note is that we’re including our dist folder in version control, as it’s not in the .gitignore file. This is unusual. More on this below.</p><p>Stage all the non-ignored files so you can review them before you commit.</p><pre>git add .</pre><p>Now let’s commit our files.</p><pre>git commit -m &quot;Committing a working base project&quot;</pre><h3>Heroku</h3><p>Let’s deploy to Heroku. I’ll assume you have heroku installed and you are logged in. If this isn’t the case, take short detour to read the at least the first three points of the Heroku’s getting started with node.js referenced at the top of the post. It’s pretty short and sweet. See you back here soon.</p><p>In the root of your project type the command.</p><pre>heroku create</pre><p>This sets up a remote on existing git repo so you can push to a remote repo. I’m sure it does more than that, but I’ve not dug into it. You can see the remote with the git remote command.</p><pre>git remote -v</pre><p>When you push to Heroku it will automatically fetch the dependencies as defined in your package.json and then run the start script. Push your code in your master branch to the heroku remote. You should see a build process in your terminal.</p><pre>git push heroku master</pre><p>The push and build should succeed, but the application should fail. You may be able to determine why with the heroku’s log command.</p><pre>heroku logs</pre><p>The failure is because we missed a few things. I left these points out of the main development section of the post as I wanted a clear separation of getting the local project work verses the Heroku deployment.</p><ol><li>A start script is need in your package.json scripts section</li><li>A Procfile that points to a built version of the project</li><li>Cors needs to be used to respond to remote requests</li></ol><p>For the start script, it’s really just looking for how to start the application. We’ve already started the project directly with the following.</p><pre>node dist/main.js</pre><p>The new start script added to scripts section of the package.json file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7c92e922efb3e70f516d97823eac8b1/href">https://medium.com/media/f7c92e922efb3e70f516d97823eac8b1/href</a></iframe><p>Recall how we didn’t excluded our dist folder in our .gitignore file? That was so we could refer to the transpiled code. Although webpack is managing the build process for us, it’s only doing so on the developers machine. It’s not rebuilding the main.js on Heroku. That means it needs to be included in our git repo so that Heroku will get a copy when they get our code.</p><p>A small improvement we can make, even if it’s not functionally necessary is to build the project in production mode. This will perform many optimizations.</p><p>Add the following script to the package.json file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e34b2bb6ca12e0cb574d9897c5539cc6/href">https://medium.com/media/e34b2bb6ca12e0cb574d9897c5539cc6/href</a></iframe><p>Then run build script.</p><pre>yarn build</pre><p>You should see that the main.js has been changed by asking git</p><pre>git status</pre><p>The Procfile, among other things, defines process definitions. It’ll tell Heroku to start a new web server and hook it up the node process that’s running our transpiled code.</p><p><a href="https://devcenter.heroku.com/articles/getting-started-with-nodejs#define-a-procfile">Getting Started on Heroku with Node.js | Heroku Dev Center</a></p><p>In the root of the project add a new file name Procfile with the following in it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/20ee68081e038fda0e51ed02c41a453e/href">https://medium.com/media/20ee68081e038fda0e51ed02c41a453e/href</a></iframe><p>To respond to requests from other origins we’ll need to use the cors package.</p><pre>yarn add cors</pre><p>Then reference and use cors. Adjust the contents of the index.js file so as to reference the cors library and use it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac2ad3ba0cc9367b807519732e1c9c60/href">https://medium.com/media/ac2ad3ba0cc9367b807519732e1c9c60/href</a></iframe><p>At this point we should be ready to try again. Stage all our changes in git.</p><pre>git add .</pre><p>Commit our changes.</p><pre>git commit -m &quot;Added start script. Replace the main.js with a production version. Added Procfile and cors.&quot;</pre><p>Push our changes to heroku.</p><pre>git push heroku master</pre><p>At this point the project should build fine on Heroku. It provides us with a url so that we can interact via our browser.</p><h3>Summary</h3><p>We covered a lot in the post. I didn’t get into many of the details as the post was already on the long side. I really didn’t think that there were so many steps until writing this post. I hope you learned a thing or two. I know I did while writing this.</p><p>Please recall that this is still a minimal sample as the server is still wide open and it doesn’t do much. Use it for learning, but there are a lot of improvements before this would be a viable application. If you have issues please note them in the comments. I’ll respond when I can and update the post accordingly.</p><h3>References</h3><ul><li><a href="https://www.valentinog.com/blog/webpack-4-tutorial/">Webpack 4 Tutorial: from 0 Conf to Production Mode (Updated)</a></li><li><a href="https://medium.com/@kimtnguyen/how-to-deploy-es6-node-js-express-back-end-to-heroku-7e6743e8d2ff">How to Deploy ES6 Node.js &amp; Express back-end to Heroku</a></li><li><a href="https://jlongster.com/Backend-Apps-with-Webpack--Part-I">Backend Apps with Webpack (Part I)</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af6121c90c6a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>