From 850704705f1b2fe9e7bd24d5ac592aff3601ac66 Mon Sep 17 00:00:00 2001 From: Tony Air Date: Mon, 28 Dec 2020 06:29:43 +0700 Subject: [PATCH] Webpack 5 update + minor fixtures --- app/_config/map.yml | 2 +- app/_config/requirements.yml | 2 +- app/src/Models/Notification.php | 1 + composer.json | 2 +- package.json | 30 +++---- webpack.config.common.js | 82 ++----------------- .../webpack.config.js => webpack.config.js | 0 ...config.serve.js => webpack.config.serve.js | 0 {webpack5 => webpack4}/package.json | 30 ++++--- .../webpack.config.common.js | 82 +++++++++++++++++-- .../webpack.config.dev.js | 0 .../webpack.config.prod.js | 0 .../webpack.configuration.js | 0 13 files changed, 116 insertions(+), 115 deletions(-) rename webpack5/webpack.config.js => webpack.config.js (100%) rename webpack5/webpack.config.serve.js => webpack.config.serve.js (100%) rename {webpack5 => webpack4}/package.json (86%) rename {webpack5 => webpack4}/webpack.config.common.js (61%) rename webpack.config.dev.js => webpack4/webpack.config.dev.js (100%) mode change 100755 => 100644 rename webpack.config.prod.js => webpack4/webpack.config.prod.js (100%) mode change 100755 => 100644 rename {webpack5 => webpack4}/webpack.configuration.js (100%) diff --git a/app/_config/map.yml b/app/_config/map.yml index 713ad42..a5d864d 100644 --- a/app/_config/map.yml +++ b/app/_config/map.yml @@ -7,7 +7,7 @@ After: SilverStripe\Core\Injector\Injector: A2nt\SilverStripeMapboxField\MarkerExtension: properties: - geocoder: %$Symbiote\Addressable\MapboxGeocodeService + geocoder: '%$Symbiote\Addressable\MapboxGeocodeService' Symbiote\Addressable\GeocodeServiceInterface: class: Symbiote\Addressable\MapboxGeocodeService diff --git a/app/_config/requirements.yml b/app/_config/requirements.yml index 7af9d52..cd020d7 100644 --- a/app/_config/requirements.yml +++ b/app/_config/requirements.yml @@ -33,7 +33,7 @@ SilverStripe\Core\Injector\Injector: SilverStripe\Assets\Storage\GeneratedAssetHandler.custom-generated-assets: class: SilverStripe\Assets\Flysystem\GeneratedAssets properties: - Filesystem: %$League\Flysystem\Filesystem.custom-filesystem + Filesystem: '%$League\Flysystem\Filesystem.custom-filesystem' # Assign this generator to the requirements builder SilverStripe\View\Requirements_Backend: properties: diff --git a/app/src/Models/Notification.php b/app/src/Models/Notification.php index 763077a..646583e 100644 --- a/app/src/Models/Notification.php +++ b/app/src/Models/Notification.php @@ -24,6 +24,7 @@ class Notification extends DataObject 'Content' => 'Text', 'DateOn' => 'Date', 'DateOff' => 'Date', + 'Area' => 'Enum("Site","Site")', ]; private static $has_one = [ diff --git a/composer.json b/composer.json index 0601215..5387611 100755 --- a/composer.json +++ b/composer.json @@ -42,7 +42,6 @@ "a2nt/silverstripe-mapboxfield": "dev-master", "a2nt/silverstripe-progressivewebapp": "dev-master", "bummzack/sortablefile": "*", - "barryvdh/composer-cleanup-plugin": "0.2.x", "eluceo/ical": "^0.16.0", "ezyang/htmlpurifier": "^4.13", "showpro/silverstripe-seo-images": "^1.0", @@ -70,6 +69,7 @@ "project-files-installed": [ "app/.htaccess", "app/_config.php", + "app/_config/database.yml", "app/_config/mimevalidator.yml", "app/_config/mysite.yml", "app/src/Page.php", diff --git a/package.json b/package.json index a47b4f9..3e361c3 100755 --- a/package.json +++ b/package.json @@ -13,10 +13,10 @@ "yarn": ">= 1.0.0" }, "scripts": { - "start": "cross-env NODE_ENV=development webpack-dev-server --https -d --config webpack.config.dev.js", - "dash": "cross-env NODE_ENV=development webpack-dashboard -- webpack-dev-server --config webpack.config.dev.js", - "prebuild": "rimraf app/client/dist", - "build": "cross-env NODE_ENV=production webpack -p --config webpack.config.prod.js --progress", + "start": "cross-env NODE_ENV=development webpack-dev-server --https --config webpack.config.serve.js", + "dash": "cross-env NODE_ENV=development webpack-dashboard -- webpack-dev-server --config webpack.config.serve.js", + "prebuild": "rimraf ./app/client/dist", + "build": "cross-env NODE_ENV=production webpack --progress --stats-all", "lint:check": "eslint ./app/client/src --config .eslintrc && sass-lint ./app/client/src --config .sasslintrc -v -q", "lint:fix": "eslint ./app/client/src --config .eslintrc --fix && sass-lint ./app/client/src --config .sasslintrc -v -q --fix", "lint:js": "eslint ./app/client/src --config .eslintrc", @@ -31,8 +31,8 @@ "ie>=11" ], "dependencies": { - "@a2nt/meta-lightbox": "^2.7.1", - "@a2nt/ss-bootstrap-ui-webpack-boilerplate": "^2.7.0", + "@a2nt/meta-lightbox": "^2.4.0", + "@a2nt/ss-bootstrap-ui-webpack-boilerplate": "^2.6.3", "aos": "^2.3.4", "bootbox": "^5.5.2", "bootstrap": "^4.5.3", @@ -92,18 +92,14 @@ "favicons-webpack-plugin": "^4.2.0", "file-loader": "^6.2.0", "font-awesome": "^4.7.0", - "hard-source-webpack-plugin": "^0.13.1", "hoist-non-react-statics": "^3.3.2", "html-entities": "^1.4.0", "html-webpack-plugin": "^4.5.0", - "imagemin-gifsicle": "^7.0.0", + "image-minimizer-webpack-plugin": "^2.1.0", "imagemin-jpegtran": "^7.0.0", - "imagemin-optipng": "^8.0.0", - "imagemin-svgo": "^8.0.0", - "imagemin-webp": "^6.0.0", "img-optimize-loader": "^1.0.7", "loglevel": "^1.7.1", - "mini-css-extract-plugin": "^0.12.0", + "mini-css-extract-plugin": "^1.3.3", "node-sass": "^5.0.0", "object-assign": "^4.1.1", "optimize-css-assets-webpack-plugin": "^5.0.4", @@ -127,12 +123,12 @@ "strip-ansi": "^6.0.0", "style-loader": "^2.0.0", "svg-url-loader": "^7.1.1", - "terser-webpack-plugin": "^4.2.3", + "terser-webpack-plugin": "^5.0.3", "url-loader": "^4.1.1", - "webpack": "^4.44.2", - "webpack-cli": "^3.3.12", - "webpack-dev-server": "^3.11.0", - "webpack-manifest-plugin": "^2.2.0", + "webpack": "^5.11.0", + "webpack-cli": "^4.2.0", + "webpack-dev-server": "^4.0.0-beta.0", + "webpack-manifest-plugin": "^3.0.0", "webpack-merge": "^5.7.3" }, "stylelint": { diff --git a/webpack.config.common.js b/webpack.config.common.js index a56f2f3..e7dfcb7 100755 --- a/webpack.config.common.js +++ b/webpack.config.common.js @@ -1,22 +1,19 @@ /* * Common Environment */ -const UIInfo = require('./node_modules/@a2nt/ss-bootstrap-ui-webpack-boilerplate/package.json'); -console.log( - 'UI: ' + - JSON.stringify(UIInfo.name) + - ' ver: ' + - JSON.stringify(UIInfo.version), -); const webpack = require('webpack'); const commonVariables = require('./webpack.configuration'); const conf = commonVariables.configuration; -const HardSourceWebpackPlugin = require('hard-source-webpack-plugin'); const path = require('path'); const filesystem = require('fs'); +const UIInfo = require('./node_modules/@a2nt/ss-bootstrap-ui-webpack-boilerplate/package.json'); +const UINAME = JSON.stringify(UIInfo.name); +const UIVERSION = JSON.stringify(UIInfo.version); +console.info(`%cUI Kit ${UINAME} ${UIVERSION}`, 'color:yellow;font-size:14px'); + const includes = {}; const modules = [ path.resolve(__dirname, conf.APPDIR, 'client', 'src'), @@ -104,81 +101,16 @@ commonVariables.themes.forEach((theme) => { module.exports = { entry: includes, - devtool: 'source-map', externals: { jquery: 'jQuery', }, - optimization: { - namedModules: true, // NamedModulesPlugin() - splitChunks: { - // CommonsChunkPlugin() - name: 'vendor', - minChunks: 2, - }, - noEmitOnErrors: true, // NoEmitOnErrorsPlugin - concatenateModules: true, //ModuleConcatenationPlugin - }, - - module: { - rules: [ - { - test: /\.jsx?$/, - //exclude: /node_modules/, - use: { - loader: 'babel-loader', - options: { - presets: ['@babel/preset-env'], //Preset used for env setup - plugins: [ - ['@babel/transform-react-jsx'], - ['react-hot-loader/babel'], - ], - cacheDirectory: true, - cacheCompression: false, - }, - }, - }, - /*{ - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/, - }, - { - test: /\.coffee?$/, - use: 'coffee-loader', - },*/ - { - test: /\.worker\.js$/, - use: { - loader: 'worker-loader', - }, - }, - ], - }, resolve: { modules: modules, alias: { + 'window.jQuery': require.resolve('jquery'), + $: require.resolve('jquery'), jquery: require.resolve('jquery'), jQuery: require.resolve('jquery'), }, }, - plugins: [ - new webpack.ProvidePlugin({ - $: 'jquery', - jQuery: 'jquery', - 'window.jQuery': 'jquery', - Popper: ['popper.js', 'default'], - Util: 'exports-loader?Util!bootstrap/js/dist/util', - Alert: 'exports-loader?Alert!bootstrap/js/dist/alert', - Button: 'exports-loader?Button!bootstrap/js/dist/button', - Carousel: 'exports-loader?Carousel!bootstrap/js/dist/carousel', - Collapse: 'exports-loader?Collapse!bootstrap/js/dist/collapse', - Dropdown: 'exports-loader?Dropdown!bootstrap/js/dist/dropdown', - Modal: 'exports-loader?Modal!bootstrap/js/dist/modal', - Tooltip: 'exports-loader?Tooltip!bootstrap/js/dist/tooltip', - Popover: 'exports-loader?Popover!bootstrap/js/dist/popover', - Scrollspy: 'exports-loader?Scrollspy!bootstrap/js/dist/scrollspy', - Tab: 'exports-loader?Tab!bootstrap/js/dist/tab', - }), - new HardSourceWebpackPlugin(), - ], }; diff --git a/webpack5/webpack.config.js b/webpack.config.js similarity index 100% rename from webpack5/webpack.config.js rename to webpack.config.js diff --git a/webpack5/webpack.config.serve.js b/webpack.config.serve.js similarity index 100% rename from webpack5/webpack.config.serve.js rename to webpack.config.serve.js diff --git a/webpack5/package.json b/webpack4/package.json similarity index 86% rename from webpack5/package.json rename to webpack4/package.json index 3e361c3..a47b4f9 100644 --- a/webpack5/package.json +++ b/webpack4/package.json @@ -13,10 +13,10 @@ "yarn": ">= 1.0.0" }, "scripts": { - "start": "cross-env NODE_ENV=development webpack-dev-server --https --config webpack.config.serve.js", - "dash": "cross-env NODE_ENV=development webpack-dashboard -- webpack-dev-server --config webpack.config.serve.js", - "prebuild": "rimraf ./app/client/dist", - "build": "cross-env NODE_ENV=production webpack --progress --stats-all", + "start": "cross-env NODE_ENV=development webpack-dev-server --https -d --config webpack.config.dev.js", + "dash": "cross-env NODE_ENV=development webpack-dashboard -- webpack-dev-server --config webpack.config.dev.js", + "prebuild": "rimraf app/client/dist", + "build": "cross-env NODE_ENV=production webpack -p --config webpack.config.prod.js --progress", "lint:check": "eslint ./app/client/src --config .eslintrc && sass-lint ./app/client/src --config .sasslintrc -v -q", "lint:fix": "eslint ./app/client/src --config .eslintrc --fix && sass-lint ./app/client/src --config .sasslintrc -v -q --fix", "lint:js": "eslint ./app/client/src --config .eslintrc", @@ -31,8 +31,8 @@ "ie>=11" ], "dependencies": { - "@a2nt/meta-lightbox": "^2.4.0", - "@a2nt/ss-bootstrap-ui-webpack-boilerplate": "^2.6.3", + "@a2nt/meta-lightbox": "^2.7.1", + "@a2nt/ss-bootstrap-ui-webpack-boilerplate": "^2.7.0", "aos": "^2.3.4", "bootbox": "^5.5.2", "bootstrap": "^4.5.3", @@ -92,14 +92,18 @@ "favicons-webpack-plugin": "^4.2.0", "file-loader": "^6.2.0", "font-awesome": "^4.7.0", + "hard-source-webpack-plugin": "^0.13.1", "hoist-non-react-statics": "^3.3.2", "html-entities": "^1.4.0", "html-webpack-plugin": "^4.5.0", - "image-minimizer-webpack-plugin": "^2.1.0", + "imagemin-gifsicle": "^7.0.0", "imagemin-jpegtran": "^7.0.0", + "imagemin-optipng": "^8.0.0", + "imagemin-svgo": "^8.0.0", + "imagemin-webp": "^6.0.0", "img-optimize-loader": "^1.0.7", "loglevel": "^1.7.1", - "mini-css-extract-plugin": "^1.3.3", + "mini-css-extract-plugin": "^0.12.0", "node-sass": "^5.0.0", "object-assign": "^4.1.1", "optimize-css-assets-webpack-plugin": "^5.0.4", @@ -123,12 +127,12 @@ "strip-ansi": "^6.0.0", "style-loader": "^2.0.0", "svg-url-loader": "^7.1.1", - "terser-webpack-plugin": "^5.0.3", + "terser-webpack-plugin": "^4.2.3", "url-loader": "^4.1.1", - "webpack": "^5.11.0", - "webpack-cli": "^4.2.0", - "webpack-dev-server": "^4.0.0-beta.0", - "webpack-manifest-plugin": "^3.0.0", + "webpack": "^4.44.2", + "webpack-cli": "^3.3.12", + "webpack-dev-server": "^3.11.0", + "webpack-manifest-plugin": "^2.2.0", "webpack-merge": "^5.7.3" }, "stylelint": { diff --git a/webpack5/webpack.config.common.js b/webpack4/webpack.config.common.js similarity index 61% rename from webpack5/webpack.config.common.js rename to webpack4/webpack.config.common.js index e7dfcb7..a56f2f3 100644 --- a/webpack5/webpack.config.common.js +++ b/webpack4/webpack.config.common.js @@ -1,19 +1,22 @@ /* * Common Environment */ +const UIInfo = require('./node_modules/@a2nt/ss-bootstrap-ui-webpack-boilerplate/package.json'); +console.log( + 'UI: ' + + JSON.stringify(UIInfo.name) + + ' ver: ' + + JSON.stringify(UIInfo.version), +); const webpack = require('webpack'); const commonVariables = require('./webpack.configuration'); const conf = commonVariables.configuration; +const HardSourceWebpackPlugin = require('hard-source-webpack-plugin'); const path = require('path'); const filesystem = require('fs'); -const UIInfo = require('./node_modules/@a2nt/ss-bootstrap-ui-webpack-boilerplate/package.json'); -const UINAME = JSON.stringify(UIInfo.name); -const UIVERSION = JSON.stringify(UIInfo.version); -console.info(`%cUI Kit ${UINAME} ${UIVERSION}`, 'color:yellow;font-size:14px'); - const includes = {}; const modules = [ path.resolve(__dirname, conf.APPDIR, 'client', 'src'), @@ -101,16 +104,81 @@ commonVariables.themes.forEach((theme) => { module.exports = { entry: includes, + devtool: 'source-map', externals: { jquery: 'jQuery', }, + optimization: { + namedModules: true, // NamedModulesPlugin() + splitChunks: { + // CommonsChunkPlugin() + name: 'vendor', + minChunks: 2, + }, + noEmitOnErrors: true, // NoEmitOnErrorsPlugin + concatenateModules: true, //ModuleConcatenationPlugin + }, + + module: { + rules: [ + { + test: /\.jsx?$/, + //exclude: /node_modules/, + use: { + loader: 'babel-loader', + options: { + presets: ['@babel/preset-env'], //Preset used for env setup + plugins: [ + ['@babel/transform-react-jsx'], + ['react-hot-loader/babel'], + ], + cacheDirectory: true, + cacheCompression: false, + }, + }, + }, + /*{ + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/, + }, + { + test: /\.coffee?$/, + use: 'coffee-loader', + },*/ + { + test: /\.worker\.js$/, + use: { + loader: 'worker-loader', + }, + }, + ], + }, resolve: { modules: modules, alias: { - 'window.jQuery': require.resolve('jquery'), - $: require.resolve('jquery'), jquery: require.resolve('jquery'), jQuery: require.resolve('jquery'), }, }, + plugins: [ + new webpack.ProvidePlugin({ + $: 'jquery', + jQuery: 'jquery', + 'window.jQuery': 'jquery', + Popper: ['popper.js', 'default'], + Util: 'exports-loader?Util!bootstrap/js/dist/util', + Alert: 'exports-loader?Alert!bootstrap/js/dist/alert', + Button: 'exports-loader?Button!bootstrap/js/dist/button', + Carousel: 'exports-loader?Carousel!bootstrap/js/dist/carousel', + Collapse: 'exports-loader?Collapse!bootstrap/js/dist/collapse', + Dropdown: 'exports-loader?Dropdown!bootstrap/js/dist/dropdown', + Modal: 'exports-loader?Modal!bootstrap/js/dist/modal', + Tooltip: 'exports-loader?Tooltip!bootstrap/js/dist/tooltip', + Popover: 'exports-loader?Popover!bootstrap/js/dist/popover', + Scrollspy: 'exports-loader?Scrollspy!bootstrap/js/dist/scrollspy', + Tab: 'exports-loader?Tab!bootstrap/js/dist/tab', + }), + new HardSourceWebpackPlugin(), + ], }; diff --git a/webpack.config.dev.js b/webpack4/webpack.config.dev.js old mode 100755 new mode 100644 similarity index 100% rename from webpack.config.dev.js rename to webpack4/webpack.config.dev.js diff --git a/webpack.config.prod.js b/webpack4/webpack.config.prod.js old mode 100755 new mode 100644 similarity index 100% rename from webpack.config.prod.js rename to webpack4/webpack.config.prod.js diff --git a/webpack5/webpack.configuration.js b/webpack4/webpack.configuration.js similarity index 100% rename from webpack5/webpack.configuration.js rename to webpack4/webpack.configuration.js