Skip to content

Commit

Permalink
Add Tailwind example
Browse files Browse the repository at this point in the history
  • Loading branch information
dionysiusmarquis committed Jan 25, 2021
1 parent 186f137 commit 0a0c828
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 5 deletions.
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@
"devDependencies": {
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.0",
"autoprefixer": "^10.2.3",
"postcss": "^8.2.4",
"postcss-load-config": "^3.0.0",
"rollup": "^2.3.4",
"rollup-plugin-css-only": "^3.1.0",
"rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-postcss": "^4.0.0",
"rollup-plugin-svelte": "^7.0.0",
"rollup-plugin-terser": "^7.0.0",
"svelte": "^3.0.0"
"svelte": "^3.0.0",
"svelte-preprocess": "^4.6.3",
"tailwindcss": "^2.0.2"
},
"dependencies": {
"sirv-cli": "^1.0.0"
Expand Down
2 changes: 2 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const plugins = [require('tailwindcss')]
module.exports = { plugins }
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<link rel='icon' type='image/png' href='/favicon.png'>
<link rel='stylesheet' href='/global.css'>
<link rel='stylesheet' href='/build/base.css'>
<link rel='stylesheet' href='/build/bundle.css'>

<script defer src='/build/bundle.js'></script>
Expand Down
9 changes: 8 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import resolve from '@rollup/plugin-node-resolve';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
import css from 'rollup-plugin-css-only';
import postcss from 'rollup-plugin-postcss';
import sveltePreprocess from 'svelte-preprocess';

const production = !process.env.ROLLUP_WATCH;

Expand Down Expand Up @@ -41,8 +43,13 @@ export default {
compilerOptions: {
// enable run-time checks when not in production
dev: !production
}
},
preprocess: sveltePreprocess()
}),

// To be able to import css files inside svelte `<script>`
postcss({ extract: 'base.css' }),

// we'll extract any component CSS out into
// a separate file - better for performance
css({ output: 'bundle.css' }),
Expand Down
9 changes: 6 additions & 3 deletions src/App.svelte
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<script>
import './css/tailwind.pcss'
export let name;
</script>

<main>
<h1>Hello {name}!</h1>
<p>Visit the <a href="https://svelte.dev/tutorial">Svelte tutorial</a> to learn how to build Svelte apps.</p>
<p class="text-green-900">Visit the <a href="https://svelte.dev/tutorial">Svelte tutorial</a> to learn how to build Svelte apps.</p>
</main>

<style>
<style lang="postcss">
main {
@apply p-4;
text-align: center;
padding: 1em;
max-width: 240px;
margin: 0 auto;
}
Expand Down
10 changes: 10 additions & 0 deletions src/css/tailwind.pcss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";

/** Modify your Tailwind layers etc. here **/
@layer base {
body {
@apply font-sans antialiased;
}
}
11 changes: 11 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
purge: [],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
}

0 comments on commit 0a0c828

Please sign in to comment.