Skip to content

Commit

Permalink
fix: remove tailwind viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Mar 9, 2021
1 parent a21783c commit 3ed5810
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 73 deletions.
21 changes: 2 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,31 +63,14 @@ If you were previously using `@nuxtjs/tailwindcss`, please consult the [document

This module will resolve the option key with either `windicss` or `tailwindcss`.

`viewer`

- Default: `true`
- Development only

The module internally use [tailwind-config-viewer](https://github.com/rogden/tailwind-config-viewer) to setup the `/_windicss/` route.

To disable the viewer in development, set it to false:

```js
export default {
windicss: {
viewer: false
}
}
```

`windicssOptions`
- Default:

```js
windicss: {
scan: {
dirs: ['./'],
exclude: ['.nuxt/**/*']
}
}
```

- See [options.ts](https://github.com/windicss/vite-plugin-windicss/blob/main/packages/plugin-utils/src/options.ts) for configuration reference.
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,9 @@
"test": "yarn lint && jest --verbose --detectOpenHandles"
},
"dependencies": {
"@nuxt/ufo": "^0.5.4",
"defu": "^3.2.2",
"rimraf": "^3.0.2",
"semver": "^7.3.4",
"tailwind-config-viewer": "^1.5.0",
"ufo": "^0.6.9",
"upath": "^2.0.1",
"windicss-webpack-plugin": "^0.1.1"
},
Expand Down
14 changes: 0 additions & 14 deletions src/files/middleware/viewer.js

This file was deleted.

36 changes: 1 addition & 35 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { requireNuxtVersion } from './compatibility'
import WindiCSSWebpackPlugin from 'windicss-webpack-plugin'
import { resolve } from 'upath'
import logger from './logger'
import { joinURL, withTrailingSlash } from 'ufo'
import chalk from 'chalk'
import defu from 'defu'
import { UserOptions } from '@windicss/plugin-utils'

Expand All @@ -26,10 +24,7 @@ const windicssModule: Module<ModuleOptions> = function (moduleOptions) {
}
}
}
const options = defu.arrayFn(moduleOptions, nuxt.options.tailwindcss, nuxt.options.windicss, {
windicssOptions,
viewer: nuxt.options.dev
}) as ModuleOptions
const options = defu.arrayFn(moduleOptions, nuxt.options.tailwindcss, nuxt.options.windicss, windicssOptions) as ModuleOptions

requireNuxtVersion(nuxt.constructor.version, '2.10')

Expand Down Expand Up @@ -58,35 +53,6 @@ const windicssModule: Module<ModuleOptions> = function (moduleOptions) {
nuxt.options.plugins.push(resolve(__dirname, 'files', 'plugins', 'windicss.js'))
})

/*
** Add /_windi UI
*/
if (nuxt.options.dev && options.viewer) {
const path = '/_windicss/'

// @ts-ignore
process.nuxt = process.nuxt || {}
// @ts-ignore
process.nuxt.$config = process.nuxt.$config || {}
// @ts-ignore
process.nuxt.$config.windicss = {
viewerPath: path,
getConfig: () => () => ({
theme: {},
variants: {},
plugins: [],
})
}

this.addServerMiddleware({ path, handler: resolve(__dirname, 'files', 'middleware', 'viewer.js') })

nuxt.hook('listen', () => {
const url = withTrailingSlash(joinURL(nuxt.server.listeners && nuxt.server.listeners[0] ? nuxt.server.listeners[0].url : '/', path))
nuxt.options.cli.badgeMessages.push(
`Windi CSS Viewer: ${chalk.underline.yellow(url)}`
)
})
}
}

// @ts-ignore
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1815,7 +1815,7 @@
resolved "https://registry.yarnpkg.com/@nuxt/ufo/-/ufo-0.0.3.tgz#7673a54b81c020e7aea3a9e01e09a58c494a1eca"
integrity sha512-LQkuVafVNB9+ggRF7443AX1V1rEWRs32Frk7F2qnRLf8j/SzRzxEZ99jiZqxVho72zU7NcWQ6Jy62m4fkZC6Wg==

"@nuxt/ufo@^0.5.2", "@nuxt/ufo@^0.5.4":
"@nuxt/ufo@^0.5.2":
version "0.5.4"
resolved "https://registry.yarnpkg.com/@nuxt/ufo/-/ufo-0.5.4.tgz#2e1428e2c947cc559d566c27786525bf0f40fbc8"
integrity sha512-JZOGDlt2BvLCBmLhrchhRJ6tP9PBfSWLdsHC+JVJ5Qp8/hT/2u61cSsLS30zUOwcPRaQ3y2oHNkEiKJ5v90iEQ==
Expand Down Expand Up @@ -14101,7 +14101,7 @@ table@^6.0.4:
slice-ansi "^4.0.0"
string-width "^4.2.0"

tailwind-config-viewer@^1.4.0, tailwind-config-viewer@^1.5.0:
tailwind-config-viewer@^1.4.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/tailwind-config-viewer/-/tailwind-config-viewer-1.5.0.tgz#b0a345a70f4282f305bf012fdb2d54e48a4e885f"
integrity sha512-yiQjFh/Hv9MgCmqJgIzCp74TDfwhBSS3no3vwEa094DGSk1eoaAKbzJskFFma91a0IxI8oVFOPZ+HCPiSZR16A==
Expand Down

0 comments on commit 3ed5810

Please sign in to comment.