Skip to content

Commit ed5cd8b

Browse files
authored
Merge pull request #293 from puikinsh/feature/prebuild
Feature/prebuild
2 parents 0987a8b + 50ed125 commit ed5cd8b

File tree

11 files changed

+75
-38
lines changed

11 files changed

+75
-38
lines changed

.github/workflows/release.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ jobs:
2323
- name: Build
2424
run: |
2525
npm install
26-
npm run build
27-
zip -r -j static.zip dist/*
26+
npm run release:minified
27+
zip -r -j static_minified.zip dist/*
28+
npm run release:unminified
29+
zip -r -j static_unminified.zip dist/*
2830
2931
- name: Get version
3032
run: echo "::set-output name=version::v$(./ci/getVersion.sh)"
@@ -40,7 +42,9 @@ jobs:
4042
with:
4143
name: ${{ steps.version.outputs.version }}
4244
tag_name: ${{ steps.version.outputs.version }}
43-
files: static.zip
45+
files: |
46+
static_minified.zip
47+
static_unminified.zip
4448
fail_on_unmatched_files: true
4549
prerelease: false
46-
draft: false
50+
draft: false

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323

2424
## Getting Started
25-
In order to run **Adminator** on your local machine all what you need to do is to have the prerequisites stated below installed on your machine and follow the installation steps down below.
25+
In order to run **Adminator** on your local machine all what you need to do is to have the prerequisites stated below installed on your machine and follow the installation steps down below. Prebuilt static assets can be found under [releases](https://github.com/puikinsh/Adminator-admin-dashboard/releases).
2626

2727
#### Prerequisites
2828
- Node.js

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{
22
"name": "adminator",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"private": true,
55
"description": "HTML Admin Template",
66
"scripts": {
77
"start": "webpack server",
88
"dev": "webpack-dashboard -t 'Project' -- webpack server",
99
"clean": "shx rm -rf ./dist",
1010
"build": "npm run clean && cross-env webpack",
11+
"release:minified": "npm run clean && NODE_ENV=production MINIFY=true cross-env webpack",
12+
"release:unminified": "npm run clean && NODE_ENV=production MINIFY=false cross-env webpack",
1113
"preview": "cross-env webpack server",
1214
"lint:js": "eslint ./src ./webpack ./*.js -f table --ext .js --ext .jsx",
1315
"lint:scss": "stylelint ./src/**/*.scss --syntax scss",
@@ -29,6 +31,7 @@
2931
"copy-webpack-plugin": "^9.0.0",
3032
"cross-env": "^7.0.3",
3133
"css-loader": "^5.2.6",
34+
"css-minimizer-webpack-plugin": "^4.0.0",
3235
"eslint": "^7.21.0",
3336
"eslint-config-airbnb-base": "^14.2.1",
3437
"eslint-plugin-import": "^2.23.4",
@@ -38,7 +41,7 @@
3841
"node-sass": "^4.14.1",
3942
"postcss": "^8.3.4",
4043
"postcss-loader": "^6.1.0",
41-
"postcss-preset-env": "^6.7.0",
44+
"postcss-preset-env": "7.8.0",
4245
"sass-loader": "^12.1.0",
4346
"shx": "^0.3.3",
4447
"style-loader": "^2.0.0",

src/assets/styles/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@import 'spec/settings/index';
22
@import 'spec/tools/index';
3-
@import "~bootstrap/scss/bootstrap";
3+
@import "bootstrap/scss/bootstrap";
44
@import 'spec/index';
55
@import 'vendor/index';
66

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@import 'breakpoints';
22
@import 'fonts';
3-
@import '~brand-colors/dist/latest/scss/brand-colors.latest.scss';
3+
@import 'brand-colors/dist/latest/scss/brand-colors.latest.scss';
44
@import 'materialColors';
55
@import 'baseColors';
66
@import 'borders';

src/assets/styles/vendor/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '~perfect-scrollbar/css/perfect-scrollbar';
1+
@import 'perfect-scrollbar/css/perfect-scrollbar';
22
@import 'themify-icons';
33
@import 'font-awesome';
44
@import 'perfectScrollbar';

webpack/config.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
// ---------------------
1616

1717
const
18-
path = require('path'),
19-
manifest = require('./manifest'),
18+
path = require('path'),
19+
manifest = require('./manifest'),
2020
devServer = require('./devServer'),
21-
rules = require('./rules'),
22-
plugins = require('./plugins');
21+
rules = require('./rules'),
22+
plugins = require('./plugins');
2323

24+
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
25+
const TerserPlugin = require("terser-webpack-plugin");
2426

2527
// ------------------
2628
// @Entry Point Setup
@@ -44,11 +46,20 @@ const resolve = {
4446
],
4547
};
4648

49+
const optimization = {
50+
minimize: manifest.MINIFY
51+
};
52+
53+
if (manifest.MINIFY) {
54+
optimization.minimizer = [
55+
new CssMinimizerPlugin(),
56+
new TerserPlugin()
57+
];
58+
}
4759

4860
// -----------------
4961
// @Exporting Module
5062
// -----------------
51-
5263
module.exports = {
5364
devtool: manifest.IS_PRODUCTION ? false : 'source-map',
5465
context: path.join(manifest.paths.src, manifest.entries.js),
@@ -63,6 +74,7 @@ module.exports = {
6374
module: {
6475
rules,
6576
},
77+
optimization: optimization,
6678
resolve,
6779
plugins,
6880
devServer,

webpack/manifest.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ const path = require('path');
2727
const
2828
NODE_ENV = process.env.NODE_ENV || 'development',
2929
IS_DEVELOPMENT = NODE_ENV === 'development',
30-
IS_PRODUCTION = NODE_ENV === 'production';
31-
30+
IS_PRODUCTION = NODE_ENV === 'production',
31+
MINIFY = process.env.MINIFY === 'true';
3232

3333
// ------
3434
// @Utils
@@ -82,4 +82,5 @@ module.exports = {
8282
NODE_ENV,
8383
IS_DEVELOPMENT,
8484
IS_PRODUCTION,
85+
MINIFY
8586
};

webpack/plugins/htmlPlugin.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,31 @@ const titles = {
2525
'test': 'Test',
2626
};
2727

28+
let minify = {
29+
collapseWhitespace: false,
30+
minifyCSS: false,
31+
minifyJS: false,
32+
removeComments: true,
33+
useShortDoctype: false,
34+
};
35+
36+
if (manifest.MINIFY) {
37+
minify = {
38+
collapseWhitespace: true,
39+
minifyCSS: true,
40+
minifyJS: true,
41+
removeComments: true,
42+
useShortDoctype: true,
43+
};
44+
}
45+
46+
2847
module.exports = Object.keys(titles).map(title => {
2948
return new HtmlWebpackPlugin({
3049
template: path.join(manifest.paths.src, `${title}.html`),
3150
path: manifest.paths.build,
3251
filename: `${title}.html`,
3352
inject: true,
34-
minify: {
35-
collapseWhitespace: true,
36-
minifyCSS: true,
37-
minifyJS: true,
38-
removeComments: true,
39-
useShortDoctype: true,
40-
},
53+
minify: minify
4154
});
4255
});

webpack/rules/css.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const loaders = [
3131
loader: 'css-loader',
3232
options: {
3333
sourceMap : manifest.IS_DEVELOPMENT,
34-
// minimize : manifest.IS_PRODUCTION,
3534
importLoaders: 1,
3635
},
3736
},
@@ -45,10 +44,9 @@ const loaders = [
4544
if (manifest.IS_PRODUCTION) {
4645
rule = {
4746
test: /\.css$/,
48-
// loader: ExtractTextPlugin({
49-
// use: loaders,
50-
// }),
51-
use: [ExtractTextPlugin.loader, loaders],
47+
use: [{
48+
loader: ExtractTextPlugin.loader,
49+
}].concat(loaders),
5250
};
5351
}
5452

webpack/rules/sass.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
const
1717
manifest = require('../manifest'),
1818
path = require('path'),
19-
cssNext = require('postcss-preset-env');
20-
19+
cssNext = require('postcss-preset-env'),
20+
ExtractTextPlugin = require('mini-css-extract-plugin');
2121

2222
// ---------------
2323
// @Common Loaders
@@ -27,8 +27,7 @@ const loaders = [
2727
{
2828
loader: 'css-loader',
2929
options: {
30-
sourceMap : manifest.IS_DEVELOPMENT,
31-
// minimize : manifest.IS_PRODUCTION,
30+
sourceMap : manifest.IS_DEVELOPMENT
3231
},
3332
},
3433
{
@@ -49,21 +48,28 @@ const loaders = [
4948
options: {
5049
sourceMap: manifest.IS_DEVELOPMENT,
5150
sassOptions: {
51+
outputStyle: manifest.MINIFY ? 'compressed' : 'expanded',
5252
includePaths: [
5353
path.join('../../', 'node_modules'),
5454
path.join(manifest.paths.src, 'assets', 'styles'),
5555
path.join(manifest.paths.src, ''),
5656
],
5757
},
58-
},
59-
},
58+
}
59+
}
6060
];
6161

62+
if (manifest.IS_PRODUCTION) {
63+
loaders.unshift(ExtractTextPlugin.loader);
64+
} else {
65+
loaders.unshift({
66+
loader: 'style-loader',
67+
});
68+
}
69+
6270
const rule = {
6371
test: /\.scss$/,
64-
use: [{
65-
loader: 'style-loader',
66-
}].concat(loaders),
72+
use: loaders
6773
};
6874

6975
// -----------------

0 commit comments

Comments
 (0)