Skip to content

Commit

Permalink
Add scss (#5)
Browse files Browse the repository at this point in the history
* feat(add-scss): added scss support
  • Loading branch information
mattnolting authored Jun 1, 2020
1 parent 80193b8 commit 1b5adae
Show file tree
Hide file tree
Showing 8 changed files with 722 additions and 72 deletions.
706 changes: 690 additions & 16 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"build:storybook": "build-storybook"
},
"devDependencies": {
"@patternfly/patternfly": "^4.10.27",
"@storybook/addon-actions": "^5.3.14",
"@storybook/addon-info": "^5.3.14",
"@storybook/addon-links": "^5.3.14",
Expand Down Expand Up @@ -52,6 +53,7 @@
"imagemin": "^7.0.0",
"jest": "^25.1.0",
"mini-css-extract-plugin": "^0.9.0",
"node-sass": "^4.14.1",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"prettier": "^1.15.2",
"prop-types": "^15.6.1",
Expand All @@ -62,6 +64,7 @@
"react-dom": "^16.11.0",
"regenerator-runtime": "^0.13.3",
"rimraf": "^3.0.2",
"sass-loader": "^8.0.2",
"style-loader": "^1.1.3",
"svg-url-loader": "^4.0.0",
"terser-webpack-plugin": "^2.3.5",
Expand Down
3 changes: 3 additions & 0 deletions src/app/app.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
html, body, #root {
height: 100%;
}
2 changes: 1 addition & 1 deletion src/app/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from 'react';
import '@patternfly/react-core/dist/styles/base.css';
import '@app/app.scss';
import { BrowserRouter as Router } from 'react-router-dom';
import { AppLayout } from '@app/AppLayout/AppLayout';
import { AppRoutes } from '@app/routes';
import '@app/app.css';

const App: React.FunctionComponent = () => (
<Router>
Expand Down
4 changes: 4 additions & 0 deletions src/app/pf-core.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@import '@patternfly/patternfly/sass-utilities/colors.scss';
@import '@patternfly/patternfly/sass-utilities/functions.scss';
@import '@patternfly/patternfly/sass-utilities/mixins.scss';
@import '@patternfly/patternfly/sass-utilities/scss-variables.scss';
21 changes: 20 additions & 1 deletion webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const Dotenv = require('dotenv-webpack');
const BG_IMAGES_DIRNAME = 'bgimages';
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = env => {

Expand Down Expand Up @@ -106,7 +107,21 @@ module.exports = env => {
}
}
]
}
},
{
test: /\.s?css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: process.env.NODE_ENV === 'development',
reloadAll: true
},
},
'css-loader',
'sass-loader'
],
},
]
},
output: {
Expand All @@ -120,6 +135,10 @@ module.exports = env => {
new Dotenv({
systemvars: true,
silent: true
}),
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[name].bundle.css'
})
],
resolve: {
Expand Down
19 changes: 0 additions & 19 deletions webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,5 @@ module.exports = merge(common('development'), {
hot: true,
overlay: true,
open: true
},
module: {
rules: [
{
test: /\.css$/,
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules/patternfly'),
path.resolve(__dirname, 'node_modules/@patternfly/patternfly'),
path.resolve(__dirname, 'node_modules/@patternfly/react-styles/css'),
path.resolve(__dirname, 'node_modules/@patternfly/react-core/dist/styles/base.css'),
path.resolve(__dirname, 'node_modules/@patternfly/react-core/dist/esm/@patternfly/patternfly'),
path.resolve(__dirname, 'node_modules/@patternfly/react-core/node_modules/@patternfly/react-styles/css'),
path.resolve(__dirname, 'node_modules/@patternfly/react-table/node_modules/@patternfly/react-styles/css'),
path.resolve(__dirname, 'node_modules/@patternfly/react-inline-edit-extension/node_modules/@patternfly/react-styles/css')
],
use: ["style-loader", "css-loader"]
}
]
}
});
36 changes: 1 addition & 35 deletions webpack.prod.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,8 @@
const path = require('path');
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const TerserJSPlugin = require('terser-webpack-plugin');

module.exports = merge(common('production'), {
mode: 'production',
devtool: 'source-map',
optimization: {
minimizer: [
new TerserJSPlugin({}),
new OptimizeCSSAssetsPlugin({})
],
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[name].bundle.css'
})
],
module: {
rules: [
{
test: /\.css$/,
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules/patternfly'),
path.resolve(__dirname, 'node_modules/@patternfly/patternfly'),
path.resolve(__dirname, 'node_modules/@patternfly/react-styles/css'),
path.resolve(__dirname, 'node_modules/@patternfly/react-core/dist/styles/base.css'),
path.resolve(__dirname, 'node_modules/@patternfly/react-core/dist/esm/@patternfly/patternfly'),
path.resolve(__dirname, 'node_modules/@patternfly/react-core/node_modules/@patternfly/react-styles/css'),
path.resolve(__dirname, 'node_modules/@patternfly/react-table/node_modules/@patternfly/react-styles/css'),
path.resolve(__dirname, 'node_modules/@patternfly/react-inline-edit-extension/node_modules/@patternfly/react-styles/css')
],
use: [MiniCssExtractPlugin.loader, 'css-loader']
}
]
}
devtool: 'source-map'
});

0 comments on commit 1b5adae

Please sign in to comment.