Skip to content

Commit

Permalink
Added the ability to generate both compressed and expanded css
Browse files Browse the repository at this point in the history
scripts/render-scss.js will now create dist/css/styles.css and dist/css/styles.min.css with it defaulting to the minified css when linking the stylesheet.
  • Loading branch information
ericsizemore committed Mar 11, 2024
1 parent a228547 commit bb858fe
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 36 deletions.
2 changes: 1 addition & 1 deletion dist/401.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="description" content="" />
<meta name="author" content="" />
<title>404 Error - SB Admin</title>
<link href="css/styles.css" rel="stylesheet" />
<link href="css/styles.min.css" rel="stylesheet" />
<script src="https://use.fontawesome.com/releases/v6.5.1/js/all.js" crossorigin="anonymous"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion dist/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="description" content="" />
<meta name="author" content="" />
<title>404 Error - SB Admin</title>
<link href="css/styles.css" rel="stylesheet" />
<link href="css/styles.min.css" rel="stylesheet" />
<script src="https://use.fontawesome.com/releases/v6.5.1/js/all.js" crossorigin="anonymous"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion dist/500.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="description" content="" />
<meta name="author" content="" />
<title>404 Error - SB Admin</title>
<link href="css/styles.css" rel="stylesheet" />
<link href="css/styles.min.css" rel="stylesheet" />
<script src="https://use.fontawesome.com/releases/v6.5.1/js/all.js" crossorigin="anonymous"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion dist/charts.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="description" content="" />
<meta name="author" content="" />
<title>Charts - SB Admin</title>
<link href="css/styles.css" rel="stylesheet" />
<link href="css/styles.min.css" rel="stylesheet" />
<script src="https://use.fontawesome.com/releases/v6.5.1/js/all.js" crossorigin="anonymous"></script>
</head>
<body class="sb-nav-fixed">
Expand Down
9 changes: 9 additions & 0 deletions dist/css/styles.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta name="author" content="" />
<title>Dashboard - SB Admin</title>
<link href="https://cdn.jsdelivr.net/npm/simple-datatables@9.0.0/dist/style.min.css" rel="stylesheet" />
<link href="css/styles.css" rel="stylesheet" />
<link href="css/styles.min.css" rel="stylesheet" />
<script src="https://use.fontawesome.com/releases/v6.5.1/js/all.js" crossorigin="anonymous"></script>
</head>
<body class="sb-nav-fixed">
Expand Down
2 changes: 1 addition & 1 deletion dist/layout-sidenav-light.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="description" content="" />
<meta name="author" content="" />
<title>Sidenav Light - SB Admin</title>
<link href="css/styles.css" rel="stylesheet" />
<link href="css/styles.min.css" rel="stylesheet" />
<script src="https://use.fontawesome.com/releases/v6.5.1/js/all.js" crossorigin="anonymous"></script>
</head>
<body class="sb-nav-fixed">
Expand Down
2 changes: 1 addition & 1 deletion dist/layout-static.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="description" content="" />
<meta name="author" content="" />
<title>Static Navigation - SB Admin</title>
<link href="css/styles.css" rel="stylesheet" />
<link href="css/styles.min.css" rel="stylesheet" />
<script src="https://use.fontawesome.com/releases/v6.5.1/js/all.js" crossorigin="anonymous"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion dist/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="description" content="" />
<meta name="author" content="" />
<title>Login - SB Admin</title>
<link href="css/styles.css" rel="stylesheet" />
<link href="css/styles.min.css" rel="stylesheet" />
<script src="https://use.fontawesome.com/releases/v6.5.1/js/all.js" crossorigin="anonymous"></script>
</head>
<body class="bg-primary">
Expand Down
2 changes: 1 addition & 1 deletion dist/password.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="description" content="" />
<meta name="author" content="" />
<title>Password Reset - SB Admin</title>
<link href="css/styles.css" rel="stylesheet" />
<link href="css/styles.min.css" rel="stylesheet" />
<script src="https://use.fontawesome.com/releases/v6.5.1/js/all.js" crossorigin="anonymous"></script>
</head>
<body class="bg-primary">
Expand Down
2 changes: 1 addition & 1 deletion dist/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="description" content="" />
<meta name="author" content="" />
<title>Register - SB Admin</title>
<link href="css/styles.css" rel="stylesheet" />
<link href="css/styles.min.css" rel="stylesheet" />
<script src="https://use.fontawesome.com/releases/v6.5.1/js/all.js" crossorigin="anonymous"></script>
</head>
<body class="bg-primary">
Expand Down
2 changes: 1 addition & 1 deletion dist/tables.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta name="author" content="" />
<title>Tables - SB Admin</title>
<link href="https://cdn.jsdelivr.net/npm/simple-datatables@9.0.0/dist/style.min.css" rel="stylesheet" />
<link href="css/styles.css" rel="stylesheet" />
<link href="css/styles.min.css" rel="stylesheet" />
<script src="https://use.fontawesome.com/releases/v6.5.1/js/all.js" crossorigin="anonymous"></script>
</head>
<body class="sb-nav-fixed">
Expand Down
36 changes: 18 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scripts/build-scss.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
const renderSCSS = require('./render-scss');

renderSCSS();
renderSCSS(true);
14 changes: 8 additions & 6 deletions scripts/render-scss.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
'use strict';
const autoprefixer = require('autoprefixer')
const autoprefixer = require('autoprefixer');
const fs = require('fs');
const packageJSON = require('../package.json');
const upath = require('upath');
const postcss = require('postcss')
const postcss = require('postcss');
const sass = require('sass');
const sh = require('shelljs');

const stylesPath = '../src/scss/styles.scss';
const destPath = upath.resolve(upath.dirname(__filename), '../dist/css/styles.css');
const destPathMin = upath.resolve(upath.dirname(__filename), '../dist/css/styles.min.css');
const loadPaths = upath.resolve(upath.dirname(__filename), '../node_modules');

module.exports = function renderSCSS() {
module.exports = function renderSCSS(compress) {
const sassStyle = compress === true ? 'compressed' : 'expanded';

const results = sass.compileString(entryPoint, {
style: sassStyle,
loadPaths: [
loadPaths
],
Expand All @@ -29,9 +32,8 @@ module.exports = function renderSCSS() {
result.warnings().forEach(warn => {
console.warn(warn.toString())
})
fs.writeFileSync(destPath, result.css.toString());
})

fs.writeFileSync(compress === true ? destPathMin : destPath, result.css.toString(), () => true);
});
};

const entryPoint = `/*!
Expand Down
3 changes: 2 additions & 1 deletion src/pug/layouts/includes/head/css.pug
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
block css
link(href='css/styles.css', rel='stylesheet')
//- link(href='css/styles.css', rel='stylesheet')
link(href='css/styles.min.css', rel='stylesheet')

0 comments on commit bb858fe

Please sign in to comment.