From f0ba4f8815f63aa78bea093daaa24944e824dea8 Mon Sep 17 00:00:00 2001 From: Bjornar Otterlei Date: Fri, 14 Aug 2020 16:58:41 +0200 Subject: [PATCH] Added - Added `--no-tablespaces` to the mysqldump command options to work around changes in MySQL Fixed - Modern config only for local dev, [fixing multi-compiler issues](https://github.com/webpack/webpack-dev-server/issues/2355) with HRM - Fix redis session config to use `App::sessionConfig()` Changed - Remove `[hash]` from dev config to eliminate potential [memory errors](https://github.com/webpack/webpack-dev-server/issues/438) - Use `[contenthash]` in production instead of [hash or chunkhash](https://github.com/webpack/webpack.js.org/issues/2096) - Readme file to give proper credit - - - --- CHANGELOG.md | 19 +++++++++++-- README.md | 3 ++ composer.json | 2 +- config/app.web.php | 25 +++++++++-------- scripts/common/common_mysql.sh | 1 + webpack.dev.js | 10 ++++--- webpack.prod.js | 51 ++++++++++++++++++---------------- 7 files changed, 69 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a811d67..77b5dd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,24 @@ ## [Unreleased] -- Explore an atomic deployment solution - Update in the readme file what to do before deployment, as well as how to deploy. -- Set up a assets volume with the aws settings ready as example. +- Set up a assets volume with the aws settings ready as example, export new seed_db. + +## [2.5.1] - 2020-08-14 + +### Added +- Added `--no-tablespaces` to the mysqldump command options to work around changes in MySQL + +### Fixed +- Modern config only for local dev, [fixing multi-compiler issues](https://github.com/webpack/webpack-dev-server/issues/2355) with HRM +- Fix redis session config to use `App::sessionConfig()` + +### Changed +- Remove `[hash]` from dev config to eliminate potential [memory errors](https://github.com/webpack/webpack-dev-server/issues/438) +- Use `[contenthash]` in production instead of [hash or chunkhash](https://github.com/webpack/webpack.js.org/issues/2096) + +### Updated +- Readme file to give proper credit ## [2.5.0] - 2020-08-09 diff --git a/README.md b/README.md index b790b59..eba84e9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # NOEN Reklamebyrå scaffolding +## What is this? +This is a Craft CMS scaffolding project based on the nystudio107´s docker scaffolding. I needed it to work with vm instead of docker, so I have adjusted it to be used with Craft Nitro. Before trying to use this, make sure you install Nitro first. I will keep updating this project based on my own preferences, as well as follow ups on nystudio107´s updates. + ## Required Technology Stack - Craft Nitro - PHP 7.4 diff --git a/composer.json b/composer.json index fae562e..e16ef2b 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "bcdo/project", "description": "A scaffolding for projects", - "version": "2.5.0", + "version": "2.5.1", "type": "project", "license": "MIT", diff --git a/config/app.web.php b/config/app.web.php index ef50150..bf1f73b 100644 --- a/config/app.web.php +++ b/config/app.web.php @@ -19,16 +19,19 @@ return [ 'components' => [ - 'session' => [ - 'class' => \yii\redis\Session::class, - 'redis' => [ - 'hostname' => App::env('REDIS_HOSTNAME'), - 'port' => App::env('REDIS_PORT'), - 'database' => App::env('REDIS_CRAFT_DB'), - ], - 'as session' => [ - 'class' => \craft\behaviors\SessionBehavior::class, - ], - ], + 'session' => static function() { + // Get the default component config + $config = craft\helpers\App::sessionConfig(); + // Override the class to use Redis' session class and our config settings + $config['class'] = yii\redis\Session::class; + $config['redis'] = [ + 'hostname' => App::env('REDIS_HOSTNAME'), + 'port' => App::env('REDIS_PORT'), + 'database' => App::env('REDIS_CRAFT_DB'), + ]; + // Instantiate and return it + return Craft::createObject($config); + }, + ], ]; diff --git a/scripts/common/common_mysql.sh b/scripts/common/common_mysql.sh index 75ce1c1..8adfae5 100644 --- a/scripts/common/common_mysql.sh +++ b/scripts/common/common_mysql.sh @@ -23,6 +23,7 @@ done # Additional arguments for mysqldump MYSQLDUMP_ADDITIONAL_ARGS="" MYSQLDUMP_ADDITIONAL_ARGS+="--add-drop-table " +MYSQLDUMP_ADDITIONAL_ARGS+="--no-tablespaces " MYSQLDUMP_ADDITIONAL_ARGS+="--comments " MYSQLDUMP_ADDITIONAL_ARGS+="--create-options " MYSQLDUMP_ADDITIONAL_ARGS+="--dump-date " diff --git a/webpack.dev.js b/webpack.dev.js index 8b7033b..b3fb61f 100644 --- a/webpack.dev.js +++ b/webpack.dev.js @@ -43,7 +43,7 @@ const configureImageLoader = () => { { loader: 'file-loader', options: { - name: 'img/[name].[hash].[ext]' + name: 'img/[name].[ext]' } } ] @@ -64,7 +64,6 @@ const configurePostcssLoader = () => { { loader: 'css-loader', options: { - url: false, importLoaders: 2, sourceMap: true } @@ -75,7 +74,10 @@ const configurePostcssLoader = () => { { loader: 'postcss-loader', options: { - sourceMap: true + sourceMap: true, + config: { + path: path.resolve(__dirname), + } } } ] @@ -87,7 +89,7 @@ module.exports = merge( common.modernConfig, { output: { - filename: path.join('./js', '[name].[hash].js'), + filename: path.join('./js', '[name].js'), publicPath: settings.devServerConfig.public() + '/', }, mode: 'development', diff --git a/webpack.prod.js b/webpack.prod.js index 9bde5c8..0344e16 100644 --- a/webpack.prod.js +++ b/webpack.prod.js @@ -79,22 +79,6 @@ const configureBanner = () => { } }; -// Configure Bundle Analyzer -const configureBundleAnalyzer = (buildType) => { - if (buildType === LEGACY_CONFIG) { - return { - analyzerMode: 'static', - reportFilename: 'report-legacy.html', - }; - } - if (buildType === MODERN_CONFIG) { - return { - analyzerMode: 'static', - reportFilename: 'report-modern.html', - }; - } -}; - // Configure Compression webpack plugin const configureCompression = () => { return { @@ -113,6 +97,22 @@ const configureCompression = () => { }; }; +// Configure Bundle Analyzer +const configureBundleAnalyzer = (buildType) => { + if (buildType === LEGACY_CONFIG) { + return { + analyzerMode: 'static', + reportFilename: 'report-legacy.html', + }; + } + if (buildType === MODERN_CONFIG) { + return { + analyzerMode: 'static', + reportFilename: 'report-modern.html', + }; + } +}; + // Configure Critical CSS const configureCriticalCss = () => { return (settings.criticalCssConfig.pages.map((row) => { @@ -167,7 +167,7 @@ const configureImageLoader = (buildType) => { { loader: 'file-loader', options: { - name: 'img/[name].[hash].[ext]' + name: 'img/[name].[contenthash].[ext]' } } ] @@ -180,7 +180,7 @@ const configureImageLoader = (buildType) => { { loader: 'file-loader', options: { - name: 'img/[name].[hash].[ext]' + name: 'img/[name].[contenthash].[ext]' } }, { @@ -274,6 +274,9 @@ const configurePostcssLoader = (buildType) => { { loader: 'postcss-loader', options: { + config: { + path: path.resolve(__dirname), + }, sourceMap: true } } @@ -349,7 +352,7 @@ module.exports = [ common.legacyConfig, { output: { - filename: path.join('./js', '[name]-legacy.[chunkhash].js'), + filename: path.join('./js', '[name]-legacy.[contenthash].js'), }, mode: 'production', devtool: 'source-map', @@ -363,7 +366,7 @@ module.exports = [ plugins: [ new MiniCssExtractPlugin({ path: path.resolve(__dirname, settings.paths.dist.base), - filename: path.join('./css', '[name].[chunkhash].css'), + filename: path.join('./css', '[name].[contenthash].css'), }), new PurgecssPlugin( configurePurgeCss() @@ -377,6 +380,9 @@ module.exports = [ new WebappWebpackPlugin( configureWebapp() ), + new CompressionPlugin( + configureCompression() + ), new CreateSymlinkPlugin( settings.createSymlinkConfig, true @@ -384,9 +390,6 @@ module.exports = [ new SaveRemoteFilePlugin( settings.saveRemoteFileConfig ), - new CompressionPlugin( - configureCompression() - ), new BundleAnalyzerPlugin( configureBundleAnalyzer(LEGACY_CONFIG), ), @@ -399,7 +402,7 @@ module.exports = [ common.modernConfig, { output: { - filename: path.join('./js', '[name].[chunkhash].js'), + filename: path.join('./js', '[name].[contenthash].js'), }, mode: 'production', devtool: 'source-map',