Browse Source

Merge pull request #293 from puikinsh/feature/prebuild

Feature/prebuild
pull/295/head v2.0.3
Aigars Silkalns 3 years ago
committed by GitHub
parent
commit
ed5cd8b8b9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 75 additions and 38 deletions
  1. +8
    -4
      .github/workflows/release.yml
  2. +1
    -1
      README.md
  3. +5
    -2
      package.json
  4. +1
    -1
      src/assets/styles/index.scss
  5. +1
    -1
      src/assets/styles/spec/settings/index.scss
  6. +1
    -1
      src/assets/styles/vendor/index.scss
  7. +17
    -5
      webpack/config.js
  8. +3
    -2
      webpack/manifest.js
  9. +20
    -7
      webpack/plugins/htmlPlugin.js
  10. +3
    -5
      webpack/rules/css.js
  11. +15
    -9
      webpack/rules/sass.js

+ 8
- 4
.github/workflows/release.yml View File

@ -23,8 +23,10 @@ jobs:
- name: Build - name: Build
run: | run: |
npm install npm install
npm run build
zip -r -j static.zip dist/*
npm run release:minified
zip -r -j static_minified.zip dist/*
npm run release:unminified
zip -r -j static_unminified.zip dist/*
- name: Get version - name: Get version
run: echo "::set-output name=version::v$(./ci/getVersion.sh)" run: echo "::set-output name=version::v$(./ci/getVersion.sh)"
@ -40,7 +42,9 @@ jobs:
with: with:
name: ${{ steps.version.outputs.version }} name: ${{ steps.version.outputs.version }}
tag_name: ${{ steps.version.outputs.version }} tag_name: ${{ steps.version.outputs.version }}
files: static.zip
files: |
static_minified.zip
static_unminified.zip
fail_on_unmatched_files: true fail_on_unmatched_files: true
prerelease: false prerelease: false
draft: false
draft: false

+ 1
- 1
README.md View File

@ -22,7 +22,7 @@
## Getting Started ## Getting Started
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.
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).
#### Prerequisites #### Prerequisites
- Node.js - Node.js


+ 5
- 2
package.json View File

@ -1,6 +1,6 @@
{ {
"name": "adminator", "name": "adminator",
"version": "2.0.2",
"version": "2.0.3",
"private": true, "private": true,
"description": "HTML Admin Template", "description": "HTML Admin Template",
"scripts": { "scripts": {
@ -8,6 +8,8 @@
"dev": "webpack-dashboard -t 'Project' -- webpack server", "dev": "webpack-dashboard -t 'Project' -- webpack server",
"clean": "shx rm -rf ./dist", "clean": "shx rm -rf ./dist",
"build": "npm run clean && cross-env webpack", "build": "npm run clean && cross-env webpack",
"release:minified": "npm run clean && NODE_ENV=production MINIFY=true cross-env webpack",
"release:unminified": "npm run clean && NODE_ENV=production MINIFY=false cross-env webpack",
"preview": "cross-env webpack server", "preview": "cross-env webpack server",
"lint:js": "eslint ./src ./webpack ./*.js -f table --ext .js --ext .jsx", "lint:js": "eslint ./src ./webpack ./*.js -f table --ext .js --ext .jsx",
"lint:scss": "stylelint ./src/**/*.scss --syntax scss", "lint:scss": "stylelint ./src/**/*.scss --syntax scss",
@ -29,6 +31,7 @@
"copy-webpack-plugin": "^9.0.0", "copy-webpack-plugin": "^9.0.0",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"css-loader": "^5.2.6", "css-loader": "^5.2.6",
"css-minimizer-webpack-plugin": "^4.0.0",
"eslint": "^7.21.0", "eslint": "^7.21.0",
"eslint-config-airbnb-base": "^14.2.1", "eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.23.4", "eslint-plugin-import": "^2.23.4",
@ -38,7 +41,7 @@
"node-sass": "^4.14.1", "node-sass": "^4.14.1",
"postcss": "^8.3.4", "postcss": "^8.3.4",
"postcss-loader": "^6.1.0", "postcss-loader": "^6.1.0",
"postcss-preset-env": "^6.7.0",
"postcss-preset-env": "7.8.0",
"sass-loader": "^12.1.0", "sass-loader": "^12.1.0",
"shx": "^0.3.3", "shx": "^0.3.3",
"style-loader": "^2.0.0", "style-loader": "^2.0.0",


+ 1
- 1
src/assets/styles/index.scss View File

@ -1,6 +1,6 @@
@import 'spec/settings/index'; @import 'spec/settings/index';
@import 'spec/tools/index'; @import 'spec/tools/index';
@import "~bootstrap/scss/bootstrap";
@import "bootstrap/scss/bootstrap";
@import 'spec/index'; @import 'spec/index';
@import 'vendor/index'; @import 'vendor/index';

+ 1
- 1
src/assets/styles/spec/settings/index.scss View File

@ -1,6 +1,6 @@
@import 'breakpoints'; @import 'breakpoints';
@import 'fonts'; @import 'fonts';
@import '~brand-colors/dist/latest/scss/brand-colors.latest.scss';
@import 'brand-colors/dist/latest/scss/brand-colors.latest.scss';
@import 'materialColors'; @import 'materialColors';
@import 'baseColors'; @import 'baseColors';
@import 'borders'; @import 'borders';

+ 1
- 1
src/assets/styles/vendor/index.scss View File

@ -1,4 +1,4 @@
@import '~perfect-scrollbar/css/perfect-scrollbar';
@import 'perfect-scrollbar/css/perfect-scrollbar';
@import 'themify-icons'; @import 'themify-icons';
@import 'font-awesome'; @import 'font-awesome';
@import 'perfectScrollbar'; @import 'perfectScrollbar';


+ 17
- 5
webpack/config.js View File

@ -15,12 +15,14 @@
// --------------------- // ---------------------
const const
path = require('path'),
manifest = require('./manifest'),
path = require('path'),
manifest = require('./manifest'),
devServer = require('./devServer'), devServer = require('./devServer'),
rules = require('./rules'),
plugins = require('./plugins');
rules = require('./rules'),
plugins = require('./plugins');
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
// ------------------ // ------------------
// @Entry Point Setup // @Entry Point Setup
@ -44,11 +46,20 @@ const resolve = {
], ],
}; };
const optimization = {
minimize: manifest.MINIFY
};
if (manifest.MINIFY) {
optimization.minimizer = [
new CssMinimizerPlugin(),
new TerserPlugin()
];
}
// ----------------- // -----------------
// @Exporting Module // @Exporting Module
// ----------------- // -----------------
module.exports = { module.exports = {
devtool: manifest.IS_PRODUCTION ? false : 'source-map', devtool: manifest.IS_PRODUCTION ? false : 'source-map',
context: path.join(manifest.paths.src, manifest.entries.js), context: path.join(manifest.paths.src, manifest.entries.js),
@ -63,6 +74,7 @@ module.exports = {
module: { module: {
rules, rules,
}, },
optimization: optimization,
resolve, resolve,
plugins, plugins,
devServer, devServer,


+ 3
- 2
webpack/manifest.js View File

@ -27,8 +27,8 @@ const path = require('path');
const const
NODE_ENV = process.env.NODE_ENV || 'development', NODE_ENV = process.env.NODE_ENV || 'development',
IS_DEVELOPMENT = NODE_ENV === 'development', IS_DEVELOPMENT = NODE_ENV === 'development',
IS_PRODUCTION = NODE_ENV === 'production';
IS_PRODUCTION = NODE_ENV === 'production',
MINIFY = process.env.MINIFY === 'true';
// ------ // ------
// @Utils // @Utils
@ -82,4 +82,5 @@ module.exports = {
NODE_ENV, NODE_ENV,
IS_DEVELOPMENT, IS_DEVELOPMENT,
IS_PRODUCTION, IS_PRODUCTION,
MINIFY
}; };

+ 20
- 7
webpack/plugins/htmlPlugin.js View File

@ -25,18 +25,31 @@ const titles = {
'test': 'Test', 'test': 'Test',
}; };
let minify = {
collapseWhitespace: false,
minifyCSS: false,
minifyJS: false,
removeComments: true,
useShortDoctype: false,
};
if (manifest.MINIFY) {
minify = {
collapseWhitespace: true,
minifyCSS: true,
minifyJS: true,
removeComments: true,
useShortDoctype: true,
};
}
module.exports = Object.keys(titles).map(title => { module.exports = Object.keys(titles).map(title => {
return new HtmlWebpackPlugin({ return new HtmlWebpackPlugin({
template: path.join(manifest.paths.src, `${title}.html`), template: path.join(manifest.paths.src, `${title}.html`),
path: manifest.paths.build, path: manifest.paths.build,
filename: `${title}.html`, filename: `${title}.html`,
inject: true, inject: true,
minify: {
collapseWhitespace: true,
minifyCSS: true,
minifyJS: true,
removeComments: true,
useShortDoctype: true,
},
minify: minify
}); });
}); });

+ 3
- 5
webpack/rules/css.js View File

@ -31,7 +31,6 @@ const loaders = [
loader: 'css-loader', loader: 'css-loader',
options: { options: {
sourceMap : manifest.IS_DEVELOPMENT, sourceMap : manifest.IS_DEVELOPMENT,
// minimize : manifest.IS_PRODUCTION,
importLoaders: 1, importLoaders: 1,
}, },
}, },
@ -45,10 +44,9 @@ const loaders = [
if (manifest.IS_PRODUCTION) { if (manifest.IS_PRODUCTION) {
rule = { rule = {
test: /\.css$/, test: /\.css$/,
// loader: ExtractTextPlugin({
// use: loaders,
// }),
use: [ExtractTextPlugin.loader, loaders],
use: [{
loader: ExtractTextPlugin.loader,
}].concat(loaders),
}; };
} }


+ 15
- 9
webpack/rules/sass.js View File

@ -16,8 +16,8 @@
const const
manifest = require('../manifest'), manifest = require('../manifest'),
path = require('path'), path = require('path'),
cssNext = require('postcss-preset-env');
cssNext = require('postcss-preset-env'),
ExtractTextPlugin = require('mini-css-extract-plugin');
// --------------- // ---------------
// @Common Loaders // @Common Loaders
@ -27,8 +27,7 @@ const loaders = [
{ {
loader: 'css-loader', loader: 'css-loader',
options: { options: {
sourceMap : manifest.IS_DEVELOPMENT,
// minimize : manifest.IS_PRODUCTION,
sourceMap : manifest.IS_DEVELOPMENT
}, },
}, },
{ {
@ -49,21 +48,28 @@ const loaders = [
options: { options: {
sourceMap: manifest.IS_DEVELOPMENT, sourceMap: manifest.IS_DEVELOPMENT,
sassOptions: { sassOptions: {
outputStyle: manifest.MINIFY ? 'compressed' : 'expanded',
includePaths: [ includePaths: [
path.join('../../', 'node_modules'), path.join('../../', 'node_modules'),
path.join(manifest.paths.src, 'assets', 'styles'), path.join(manifest.paths.src, 'assets', 'styles'),
path.join(manifest.paths.src, ''), path.join(manifest.paths.src, ''),
], ],
}, },
},
},
}
}
]; ];
if (manifest.IS_PRODUCTION) {
loaders.unshift(ExtractTextPlugin.loader);
} else {
loaders.unshift({
loader: 'style-loader',
});
}
const rule = { const rule = {
test: /\.scss$/, test: /\.scss$/,
use: [{
loader: 'style-loader',
}].concat(loaders),
use: loaders
}; };
// ----------------- // -----------------


Loading…
Cancel
Save