Skip to content

Commit

Permalink
🎐 Tailwindcss setup (#272)
Browse files Browse the repository at this point in the history
* ✨ Added tailwindcss

* πŸ”₯ Removed useless types from root
  • Loading branch information
SagnikPradhan authored Apr 23, 2021
1 parent 44b263d commit 9ac7924
Show file tree
Hide file tree
Showing 11 changed files with 1,072 additions and 37 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
web/source/typings/vendor.d.ts

server/source/prisma/

tailwind.config.js
5 changes: 5 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ plugins:
spec: '@yarnpkg/plugin-typescript'

yarnPath: .yarn/releases/yarn-sources.cjs

packageExtensions:
'@fullhuman/postcss-purgecss@*':
peerDependencies:
'postcss': '*'
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
"eslint-plugin-react": "latest",
"gitmoji-cli": "^3.2.12",
"husky": "^6.0.0",
"postcss": "^8.2.10",
"prettier": "^2.2.1",
"prettier-plugin-jsdoc": "^0.2.12",
"tailwindcss": "^2.1.1",
"typescript": "^4.1.3"
},
"homepage": "https://github.com/vegeta897/d-zone#readme",
Expand Down
8 changes: 8 additions & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"@babel/preset-react": "^7.13.13",
"@babel/preset-typescript": "^7.13.0",
"@prisma/client": "^2.20.1",
"autoprefixer": "^10.2.5",
"babel-loader": "^8.2.2",
"css-loader": "^5.2.4",
"dotenv": "^8.2.0",
"eris": "^0.15.0",
"eventemitter3": "^4.0.7",
Expand All @@ -21,9 +23,13 @@
"koa-compose": "^4.1.0",
"koa-static": "^5.0.0",
"koa-webpack": "^6.0.0",
"mini-css-extract-plugin": "^1.5.0",
"pnp-webpack-plugin": "^1.6.4",
"postcss": "^8.2.10",
"postcss-loader": "v4",
"prisma": "^2.20.1",
"socket.io": "^4.0.1",
"tailwindcss": "^2.1.1",
"tslog": "^3.1.2",
"webpack": "4",
"webpack-hot-client": "^4.2.0"
Expand All @@ -35,8 +41,10 @@
"@types/koa-compose": "^3.2.5",
"@types/koa-static": "^4.0.1",
"@types/koa-webpack": "^6",
"@types/mini-css-extract-plugin": "^1",
"@types/node": "^14.14.37",
"@types/speed-measure-webpack-plugin": "^1",
"@types/tailwindcss": "^2",
"@types/webpack": "4",
"@types/webpack-hot-client": "^4",
"ts-node": "^9.1.1",
Expand Down
31 changes: 31 additions & 0 deletions server/source/http/web/config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { Configuration } from 'webpack'
import HTMLWebpackPlugin from 'html-webpack-plugin'
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
import MiniCSSExtactWebpackPlugin from 'mini-css-extract-plugin'
// @ts-expect-error No types
import PNPWebpackPlugin from 'pnp-webpack-plugin'
import tailwindcss from 'tailwindcss'

import { join } from 'path'
export const root = (path = '') => join(process.cwd(), '../web', path)
const glob = (path: string) => root().replace('\\', '/') + path

const configuration = (dev: boolean): Configuration => ({
mode: dev ? 'development' : 'production',
Expand Down Expand Up @@ -36,6 +39,32 @@ const configuration = (dev: boolean): Configuration => ({
},
},
},
{
test: /\.css$/,

use: [
MiniCSSExtactWebpackPlugin.loader,
require.resolve('css-loader'),
{
loader: require.resolve('postcss-loader'),
options: {
implementation: require('postcss'),

postcssOptions: {
plugins: [
require('autoprefixer'),

tailwindcss({
...require(root('../tailwind.config')),

purge: [glob('/**/*.tsx'), glob('./**/*.html')],
}),
],
},
},
},
],
},
],
},

Expand All @@ -48,6 +77,8 @@ const configuration = (dev: boolean): Configuration => ({
typescriptPath: require.resolve('typescript'),
},
}),
// @ts-expect-error Webpack V4 and V5 types do not match
new MiniCSSExtactWebpackPlugin(),
],

resolve: {
Expand Down
7 changes: 5 additions & 2 deletions server/source/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ import { createHTTPServer } from './http'

/** Main entry point for runtime */
async function main() {
const logger = new Logger()

const DISCORD_TOKEN = process.env['DISCORD_TOKEN']
const PORT = process.env['PORT'] || 8080
const DEV = !process.env['PRODUCTION']
const DEV = process.env['NODE_ENV'] !== 'production'

logger.info(`Development mode`, DEV)

if (!DISCORD_TOKEN) throw new Error('DISCORD_TOKEN not set')

const logger = new Logger()
const prisma = new PrismaClient()

const httpServer = http.createServer(
Expand Down
9 changes: 9 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
purge: [],
darkMode: false,
theme: {
extend: {},
},
variants: {},
plugins: [],
}
4 changes: 3 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
"pixi.js-legacy": "^5.3.7",
"react": "^16.8.0",
"react-dom": "^16.8.0",
"socket.io-client": "^4.0.1"
"socket.io-client": "^4.0.1",
"tailwindcss": "^2.1.1"
},
"devDependencies": {
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@types/tailwindcss": "^2",
"root": "link:./source",
"server": "workspace:server",
"typescript": "^4.1.3"
Expand Down
4 changes: 3 additions & 1 deletion web/source/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import Game from './components/game'

export const App = () => {
return (
<div>
<div className="flex flex-col items-center">
<h1 className="m-2 font-bold text-4xl">D Zone</h1>

<Game />
</div>
)
Expand Down
1 change: 1 addition & 0 deletions web/source/main.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'tailwindcss/tailwind.css'
import React from 'react'
import ReactDOM from 'react-dom'
import { App } from './App'
Expand Down
Loading

0 comments on commit 9ac7924

Please sign in to comment.