Last active
November 12, 2020 09:29
-
-
Save ClimenteA/6df8716b46fbb7bde3968aff6a6a079e to your computer and use it in GitHub Desktop.
How to configure svelte with tailwind and svelte-spa-router
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npx degit sveltejs/template project-name | |
cd project-name | |
npm install | |
npm install svelte-spa-router | |
// Temporary issue postcss works only with: [email protected] (remove @9.8.6 if the issue was solved) | |
npm install [email protected] postcss-cli tailwindcss concurrently cross-env --save-dev | |
npx tailwindcss init -p | |
code . | |
touch ./public/tailwind.css | |
// Add in it the 3 lines bellow: | |
@import "tailwindcss/base"; | |
@import "tailwindcss/components"; | |
@import "tailwindcss/utilities"; | |
// In 'tailwind.config.js' file add the extensions for svelte (or vue/other) | |
purge: [ | |
'./src/**/*.html', | |
'./src/**/*.svelte', | |
'./src/*.svelte', | |
'./public/index.html' | |
], | |
// Add the index.css to the index.html file | |
<link rel='stylesheet' href='/index.css'> | |
// In package.json replace the default "scripts" commands with the ones bellow | |
"watch:tailwind": "postcss public/tailwind.css -o public/index.css -w", | |
"build:tailwind": "cross-env NODE_ENV=production postcss public/tailwind.css -o public/index.css", | |
"build": "npm run build:tailwind && rollup -c", | |
"start": "sirv public", | |
"serve": "sirv public -p 80", | |
"dev": "concurrently \"rollup -c -w\" \"npm run watch:tailwind\"" | |
// Run and see if all works as expected | |
npm run dev |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment