-
Notifications
You must be signed in to change notification settings - Fork 300
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
Guide on Styling and CSS options #336
Comments
The steps to include CSS in a webpack project are also not intuitive for beginners. Instructions should be documented somewhere. Posting here in the meantime. A failed attempt (click to expand)For example, this was my initial flawed interpretation of one suggestion:
So, if I have a directory structure like this:
Do I put this in "use strict";
import '../dev/tailwind.css'; This compiles, but the js contents do not get incorporated into the final bundle. I seems to be skipped when the compiler determines it's an unnecessary FFI module. So then if I add this line: exports.dummy = 5; I get a FFI parsing error on The actual solutions are to either: 1. "use strict";
import './tailwind.css'; Then add this file as an entry point in entry: {
"index.js": [
"./dev/tailwind.js",
"./dev/index.js",
], Edit: Improved technique described in next post. 2.
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
template: "./dev/index.html"
}),
],
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My Title</title>
<link rel="stylesheet" href="/dev/tailwind.css">
</head>
<body></body>
</html> |
Your first solution can be simplified a bit by dropping the JavaScript file and referring to ./dev/tailwind.css directly in the entry: "index.js": [
- "./dev/tailwind.js",
+ "./dev/tailwind.css",
"./dev/index.js",
], Also your initial attempt can be fixed by importing the stylesheet with the CommonJS "use strict";
-import '../dev/tailwind.css';
+exports.stylesheet = require('../../dev/tailwind.css'); +foreign import stylesheet :: Unit This is quite useful for CSS modules, because then you can type the stylesheet with |
Great tips! |
This question comes up a lot. A guide listing the options would be helpful, and I don't think that would break scope as long at it's mostly links and summaries.
I'd like to aggregate material from:
The text was updated successfully, but these errors were encountered: