Setting up TailwindCSS + SASS with EmberJS

Let’s get started!

Creating an EmberJS project

See https://guides.emberjs.com/release/getting-started/quick-start/ for more information.

If you haven’t already, you can install the Ember CLI using the following command:

npm install -g e…


This content originally appeared on DEV Community and was authored by Catherine Chen

Let's get started!

Creating an EmberJS project

See https://guides.emberjs.com/release/getting-started/quick-start/ for more information.

If you haven't already, you can install the Ember CLI using the following command:

npm install -g ember-cli

Then, create a fresh new Ember application:

ember new my-ember-app --lang en

Navigate into the directory of your new Ember app (cd my-ember-app) before running any of the commands in the next section.

Adding TailwindCSS + SASS

First, let's begin by installing the necessary dependencies:

npm i -D ember-cli-postcss postcss-scss autoprefixer tailwindcss

Next, create your tailwind.config.js file in the root directory:

npx tailwind init

Update module.exports to reflect something like this:

// tailwind.config.js

module.exports = {
    content: ["./app/**/*.{gjs,gts,hbs,html,js,ts}"],
    // ...
}

Add the following options to ember-cli-build.js:

// ember-cli-build.js

// ...

module.exports = function (defaults) {
    const app = new EmberApp(defaults, {
+       postcssOptions: {
+           compile: {
+               extension: "scss",
+               enabled: true,
+               parser: require("postcss-scss"),
+               plugins: [
+                   {
+                       module: require("autoprefixer"),
+                       options: {},
+                   },
+                   {
+                       module: require("tailwindcss"),
+                       options: {
+                           config: "./tailwind.config.js",
+                       },
+                   },
+               ],
+           },
+       },
    });

    return app.toTree();
};

Note that you will need to restart the server (run npm start again) to see changes after making edits to ember-cli-build.js.

Rename app/styles/app.css to app/styles/app.scss.

Conclusion

And that's it! If you have any questions or comments, feel free to let me know.

If you would like to see the full code for this tutorial, check out klickers/embertwscss.


This content originally appeared on DEV Community and was authored by Catherine Chen


Print Share Comment Cite Upload Translate Updates
APA

Catherine Chen | Sciencx (2023-05-02T22:09:11+00:00) Setting up TailwindCSS + SASS with EmberJS. Retrieved from https://www.scien.cx/2023/05/02/setting-up-tailwindcss-sass-with-emberjs/

MLA
" » Setting up TailwindCSS + SASS with EmberJS." Catherine Chen | Sciencx - Tuesday May 2, 2023, https://www.scien.cx/2023/05/02/setting-up-tailwindcss-sass-with-emberjs/
HARVARD
Catherine Chen | Sciencx Tuesday May 2, 2023 » Setting up TailwindCSS + SASS with EmberJS., viewed ,<https://www.scien.cx/2023/05/02/setting-up-tailwindcss-sass-with-emberjs/>
VANCOUVER
Catherine Chen | Sciencx - » Setting up TailwindCSS + SASS with EmberJS. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/05/02/setting-up-tailwindcss-sass-with-emberjs/
CHICAGO
" » Setting up TailwindCSS + SASS with EmberJS." Catherine Chen | Sciencx - Accessed . https://www.scien.cx/2023/05/02/setting-up-tailwindcss-sass-with-emberjs/
IEEE
" » Setting up TailwindCSS + SASS with EmberJS." Catherine Chen | Sciencx [Online]. Available: https://www.scien.cx/2023/05/02/setting-up-tailwindcss-sass-with-emberjs/. [Accessed: ]
rf:citation
» Setting up TailwindCSS + SASS with EmberJS | Catherine Chen | Sciencx | https://www.scien.cx/2023/05/02/setting-up-tailwindcss-sass-with-emberjs/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.