Skip to content

Commit

Permalink
build(tools): build theme with webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
adorade committed Mar 14, 2023
1 parent 0b5ea6c commit 5d3d4b5
Show file tree
Hide file tree
Showing 23 changed files with 1,534 additions and 133 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Node CI

on:
push:
branches: [main, develop, v1-dev]
branches: [main, v1-dev]
pull_request:
branches: [main]

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ Thumbs.db
# Folders to ignore
/archive/
/node_modules/
/build/
3 changes: 0 additions & 3 deletions .rtlcssrc.json

This file was deleted.

25 changes: 25 additions & 0 deletions .webpack/webpack.common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const path = require('path');
const { merge } = require('webpack-merge');
const { extractScss } = require('./webpack.parts.js');

const themePath = path.resolve(__dirname, '../themes/boodark');

exports.commonConfig = ({ mode }) => (
merge(
{
mode,
devtool: 'source-map',
entry: {
'theme': themePath + '/scss/theme.scss',
'theme-nord': themePath + '/scss/theme-nord.scss',
'theme-teal': themePath + '/scss/theme-teal.scss',
'theme-orange': themePath + '/scss/theme-orange.scss',
},
output: {
filename: '../../../build/[name].js',
path: themePath + '/css',
},
},
extractScss(),
)
);
19 changes: 19 additions & 0 deletions .webpack/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const { merge } = require('webpack-merge');
const { commonConfig } = require('./webpack.common.js');
const { productionConfig } = require('./webpack.production.js');
const { developmentConfig } = require('./webpack.development.js');

const getConfig = ({ mode }) => {
switch (mode) {
case 'production':
return merge(commonConfig({ mode }), productionConfig());
case 'development':
return merge(commonConfig({ mode }), developmentConfig());
default:
throw new Error(`Trying to use an unknown mode, ${mode}`);
}
};

module.exports = (env, options) => getConfig({
mode: options.mode ?? 'production',
});
4 changes: 4 additions & 0 deletions .webpack/webpack.development.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
exports.developmentConfig = () => ({
name: 'CSS development',
// devtool: 'source-map',
});
32 changes: 32 additions & 0 deletions .webpack/webpack.parts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const autoprefixer = require('autoprefixer');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const RtlCssPlugin = require('rtlcss-webpack-plugin');

exports.extractScss = () => ({
module: {
rules: [
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{ loader: 'css-loader', options: { url: false } },
{ loader: 'postcss-loader', options: {
postcssOptions: {
plugins: [ autoprefixer() ],
},
}},
{ loader: 'sass-loader' },
],
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css',
}),
new RtlCssPlugin({
filename: '[name].rtl.css',
}),
],
});
22 changes: 22 additions & 0 deletions .webpack/webpack.production.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');

exports.productionConfig = () => ({
name: 'CSS production',
optimization: {
minimize: true,
minimizer: [
new CssMinimizerPlugin({
minify: CssMinimizerPlugin.cssoMinify,
minimizerOptions: {
forceMediaMerge: true,
comments: false,
},
}),
],
},
performance: {
hints: 'warning',
maxAssetSize: 285000,
maxEntrypointSize: 570000,
},
});
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The best way to see **BooDark** in action is to try it on **phpMyAdmin** demo se

## Installation

1. Download latest [release](https://github.com/adorade/boodark/releases/latest/download/boodark-v1.0.3.zip)
1. Download latest [release](https://github.com/adorade/boodark/releases/latest/download/boodark-v1.1.0.zip)
2. Extract the archive files
3. Go to the phpMyAdmin files (C:\xampp\phpmyadmin for XAMPP) then go to the `themes` folder and add here the `boodark` folder
4. Select `BooDark` theme on the home page
Expand Down Expand Up @@ -67,7 +67,7 @@ To build the theme or customize it with your preferences you must have **Node**,
# production, minified files
yarn run build
# development
yarn run css-dev
yarn run build:dev
```

6. Theme files are in `themes/boodark`.
Expand Down
38 changes: 24 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
{
"name": "boodark",
"version": "1.1.0",
"version": "1.1.0-dev",
"description": "Bootstrap Dark theme for phpMyAdmin",
"repository": "https://github.com/adorade/boodark.git",
"author": "Adorade",
"scripts": {
"postinstall": "yarn run build",
"build": "yarn run css-clean && yarn run css-compile && yarn run css-prefix && yarn run css-rtl",
"css-clean": "rm -rf themes/boodark/css",
"css-compile": "sass themes/boodark/scss:themes/boodark/css --style=compressed",
"css-dev": "yarn run css-clean && sass themes/boodark/scss:themes/boodark/css --style=expanded --watch",
"css-lint": "stylelint themes/boodark/scss/*.scss",
"css-prefix": "postcss themes/boodark/css/*.css --use autoprefixer --replace",
"css-rtl": "rtlcss -c .rtlcssrc.json themes/boodark/css/theme.css"
"build": "yarn run build:prod",
"build:analyze": "webpack --progress --mode=production --analyze",
"build:dev": "webpack --progress --mode=development",
"build:prod": "webpack --progress --mode=production",
"watch": "webpack --progress --watch --mode=development",
"css:lint": "stylelint 'public/themes/boodark/scss/*.scss'"
},
"dependencies": {
"autoprefixer": "10.4.13",
"@babel/runtime": "7.21.0",
"@popperjs/core": "2.11.6",
"autoprefixer": "10.4.14",
"bootstrap": "5.2.3",
"css-loader": "6.7.3",
"css-minimizer-webpack-plugin": "4.2.2",
"mini-css-extract-plugin": "2.7.3",
"postcss": "8.4.21",
"postcss-cli": "10.1.0",
"postcss-loader": "7.0.2",
"rtlcss": "4.0.0",
"sass": "1.58.3"
"rtlcss-webpack-plugin": "4.0.7",
"sass": "1.59.2",
"sass-loader": "13.2.0",
"webpack": "5.76.1",
"webpack-cli": "5.0.1",
"webpack-merge": "5.8.0"
},
"devDependencies": {
"stylelint": "14.12.0",
"stylelint-config-recommended-scss": "7.0.0",
"stylelint-config-standard-scss": "5.0.0",
"stylelint-scss": "4.3.0"
"stylelint": "14.16.1",
"stylelint-config-recommended-scss": "8.0.0",
"stylelint-config-standard-scss": "6.1.0",
"stylelint-scss": "4.4.0"
},
"engines": {
"node": ">=14"
Expand Down
5 changes: 2 additions & 3 deletions themes/boodark/css/theme-nord.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/boodark/css/theme-nord.css.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions themes/boodark/css/theme-nord.rtl.css

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions themes/boodark/css/theme-orange.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/boodark/css/theme-orange.css.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions themes/boodark/css/theme-orange.rtl.css

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions themes/boodark/css/theme-teal.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/boodark/css/theme-teal.css.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions themes/boodark/css/theme-teal.rtl.css

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions themes/boodark/css/theme.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/boodark/css/theme.css.map

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions themes/boodark/css/theme.rtl.css

Large diffs are not rendered by default.

Loading

0 comments on commit 5d3d4b5

Please sign in to comment.