Skip to content

Commit

Permalink
added scss, tailwindcss support
Browse files Browse the repository at this point in the history
  • Loading branch information
amarwadi committed Jun 24, 2020
1 parent c389194 commit 6315cca
Show file tree
Hide file tree
Showing 9 changed files with 1,942 additions and 43 deletions.
43 changes: 38 additions & 5 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,40 @@
module.exports = {
const withSass = require("@zeit/next-sass");
const tailwindCss = require("tailwindcss");

module.exports = withSass({
publicRuntimeConfig: {
localeSubpaths: typeof process.env.LOCALE_SUBPATHS === 'string'
? process.env.LOCALE_SUBPATHS
: 'none',
localeSubpaths: typeof process.env.LOCALE_SUBPATHS === 'string' ?
process.env.LOCALE_SUBPATHS : 'none',
},
};
webpack(config, options) {
const rules = [{
test: /\.scss$/,
use: [{
loader: "postcss-loader",
options: {
ident: "postcss",
plugins: [
require('tailwindcss'),
require('autoprefixer'),
]
}
},
{ loader: "sass-loader" }
]
}];
return {
...config,
module: {
...config.module,
rules: [...config.module.rules, ...rules]
}
};
}});

// module.exports = {
// publicRuntimeConfig: {
// localeSubpaths: typeof process.env.LOCALE_SUBPATHS === 'string'
// ? process.env.LOCALE_SUBPATHS
// : 'none',
// },
// };
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
"start": "NODE_ENV=production node index.js"
},
"dependencies": {
"@fullhuman/postcss-purgecss": "^2.3.0",
"@material-ui/core": "^4.4.0",
"@material-ui/icons": "^4.2.1",
"babel-plugin-styled-components": "^1.10.6",
"@zeit/next-sass": "^1.0.1",
"autoprefixer": "^9.8.4",
"babel-plugin-styled-components": "latest",
"es6-promise": "4.1.1",
"express": "^4.17.1",
"immer": "^3.2.0",
Expand All @@ -19,6 +22,7 @@
"next-i18next": "^1.1.2",
"next-redux-saga": "4.0.0",
"next-redux-wrapper": "2.0.0",
"node-sass": "^4.14.1",
"prop-types": "^15.7.2",
"react": "16.9.0",
"react-dom": "16.9.0",
Expand All @@ -27,10 +31,13 @@
"redux": "4.0.1",
"redux-saga": "1.0.1",
"reselect": "^4.0.0",
"styled-components": "^4.3.2"
"styled-components": "^4.3.2",
"tailwindcss": "^1.4.6"
},
"devDependencies": {
"babel-plugin-styled-components": "latest",
"redux-devtools-extension": "2.13.2"
"postcss-preset-env": "^6.7.0",
"redux-devtools-extension": "2.13.2",
"tailwindcss": "^1.4.6"
}
}
1 change: 1 addition & 0 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ThemeProvider } from '@material-ui/styles';
import Layout from '../components/Layout';
import theme from '../themes/theme';
import CssBaseline from '@material-ui/core/CssBaseline';
import '../styles/sass/style.scss';

class MyApp extends App {

Expand Down
1 change: 1 addition & 0 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Index extends React.Component {
]
}
/>
<h1 className="test">I'm USING TAILWIND!!!</h1>
<StyledDiv>
<Typography variant="body1">
{t('title')}
Expand Down
17 changes: 17 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
...(process.env.NODE_ENV === 'production'
? {
'@fullhuman/postcss-purgecss': {
content: [
'./components/**/*.js',
'./pages/**/*.js'
],
defaultExtractor: content => content.match(/[\w-/:]+(?<!:)/g) || []
}
}
: {})
}
};
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const express = require('express');
const next = require('next');
const nextI18NextMiddleware = require('next-i18next/middleware').default;
const nextI18next = require('./i18n');
const port = process.env.PORT || 3000;
const port = process.env.PORT || 3100;
const app = next({ dev: process.env.NODE_ENV !== 'production' });
const handle = app.getRequestHandler();

Expand Down
24 changes: 24 additions & 0 deletions styles/sass/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* purgecss start ignore */
@tailwind base;
@tailwind components;
/* purgecss end ignore */


$bg-color: #212121;
$container-color: #f4f4f4;
$primary-color: #000000;
$accent-color: #F68E20;

$h1: 30px;

body {
color: $primary-color;
background-color: $bg-color;
}

.test{
font-size: $h1;
color: $accent-color;
}

@tailwind utilities;
8 changes: 8 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
purge: ['./components/**/*.js', './pages/**/*.js'],
theme: {
extend: {},
},
variants: {},
plugins: [],
}
Loading

0 comments on commit 6315cca

Please sign in to comment.