Skip to content
This repository was archived by the owner on May 8, 2021. It is now read-only.

Commit c759942

Browse files
authored
Merge pull request #13 from Atinux/master
Add NuxtJS example
2 parents e89baa0 + 12b926a commit c759942

File tree

11 files changed

+7307
-0
lines changed

11 files changed

+7307
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ A repository of examples showing how to setup Tailwind in a variety of different
55
## Available Examples
66

77
- [vue-cli](examples/vue-cli)
8+
- [nuxt](examples/nuxt)
89

910
## Requested Examples
1011

examples/nuxt/.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
5+
# local env files
6+
.env.local
7+
.env.*.local
8+
9+
# Log files
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
14+
# Editor directories and files
15+
.idea
16+
.vscode
17+
*.suo
18+
*.ntvs*
19+
*.njsproj
20+
*.sln
21+
*.sw?
22+
23+
# Nuxt files
24+
.nuxt/

examples/nuxt/README.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Nuxt
2+
3+
Setting up Tailwind with [NuxtJS](https://nuxtjs.org) is really simple, just add the [@nuxtjs/tailwindcss](https://github.com/Atinux/nuxt-tailwindcss) module:
4+
5+
```sh
6+
npm install @nuxtjs/tailwindcss
7+
```
8+
9+
Then add it to your `nuxt.config.js` file:
10+
11+
```js
12+
export default {
13+
modules: [
14+
'@nuxtjs/tailwindcss'
15+
]
16+
}
17+
```
18+
19+
That's it ✨
20+
21+
The module will:
22+
- Create a CSS file for your Tailwind styles in `assets/css/tailwind.css`:
23+
24+
```css
25+
@tailwind base;
26+
@tailwind components;
27+
@tailwind utilities;
28+
```
29+
- Import this file as global css
30+
- Create a `tailwind.config.js` file.
31+
32+
```js
33+
module.exports = {
34+
theme: {},
35+
variants: {},
36+
plugins: []
37+
}
38+
```
39+
- Configure [nuxt-purgecss](https://github.com/Developmint/nuxt-purgecss)
40+
- Set [postcss-preset-env](https://preset-env.cssdb.org) to stage 1, [learn more here](https://tailwindcss.com/docs/using-with-preprocessors#future-css-features)
41+
42+
## Project setup
43+
44+
```
45+
npm install
46+
```
47+
48+
### Compiles and hot-reloads for development
49+
50+
```
51+
npm run dev
52+
```
53+
54+
### Compiles and minifies for production
55+
56+
```
57+
npm run build
58+
```
59+
60+
### Start the server for production
61+
62+
```
63+
npm run start
64+
```
65+
66+
### Generate as a static website
67+
68+
```
69+
npm run generate
70+
```

examples/nuxt/assets/css/tailwind.css

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@import 'tailwindcss/base';
2+
@import 'tailwindcss/components';
3+
@import 'tailwindcss/utilities';

examples/nuxt/nuxt.config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export default {
2+
head: {
3+
title: 'NuxtJS + TailwindCSS',
4+
meta: [
5+
{ hid: 'charset', charset: 'utf-8' },
6+
{ hid: 'viewport', name: 'viewport', content: 'width=device-width, initial-scale=1' }
7+
]
8+
},
9+
modules: [
10+
'@nuxtjs/tailwindcss'
11+
]
12+
}

examples/nuxt/package.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "nuxt",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "nuxt",
7+
"build": "nuxt build",
8+
"start": "nuxt start",
9+
"generate": "nuxt generate"
10+
},
11+
"dependencies": {
12+
"@nuxtjs/tailwindcss": "^0.1.0",
13+
"nuxt-start": "^2.8.1"
14+
},
15+
"devDependencies": {
16+
"nuxt": "^2.8.1"
17+
}
18+
}

examples/nuxt/pages/about.vue

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<template>
2+
<div class="min-h-screen flex flex-col items-center justify-center">
3+
<h1 class="text-5xl font-bold text-teal-600">Hello from Nuxt.</h1>
4+
<n-link to="/">Home page</n-link>
5+
</div>
6+
</template>

examples/nuxt/pages/index.vue

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<template>
2+
<div class="min-h-screen flex flex-col items-center justify-center">
3+
<h1 class="text-5xl font-bold text-teal-300">Hello from Tailwind.</h1>
4+
<n-link to="/about">About page</n-link>
5+
</div>
6+
</template>

examples/nuxt/static/favicon.ico

1.36 KB
Binary file not shown.

examples/nuxt/tailwind.config.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
** TailwindCSS Configuration File
3+
**
4+
** Docs: https://tailwindcss.com/docs/configuration
5+
** Default: https://github.com/tailwindcss/tailwindcss/blob/master/stubs/defaultConfig.stub.js
6+
*/
7+
module.exports = {
8+
theme: {},
9+
variants: {},
10+
plugins: []
11+
}

0 commit comments

Comments
 (0)