From 815b190d28cc42e6f3d44d04e1f1ebaea9208cf6 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Sat, 30 Oct 2021 22:44:55 +0200 Subject: chore: convert html files to php Now I can use php to determine current env and load static CSS file if it is prod. --- composer.json | 23 ++ composer.lock | 526 +++++++++++++++++++++++++++++++++++++++ config/dotenv.php | 20 ++ config/paths.js | 15 -- config/webpack.common.js | 102 -------- config/webpack.dev.js | 91 ------- config/webpack.prod.js | 48 ---- config/webpack/paths.js | 15 ++ config/webpack/webpack.common.js | 102 ++++++++ config/webpack/webpack.dev.js | 91 +++++++ config/webpack/webpack.prod.js | 48 ++++ index.html | 77 ------ index.php | 80 ++++++ legal-notice.html | 90 ------- legal-notice.php | 93 +++++++ license.html | 93 ------- license.php | 96 +++++++ mentions-legales.html | 90 ------- mentions-legales.php | 93 +++++++ package.json | 1 + src/js/i18n/locales/en.js | 2 +- src/js/i18n/locales/fr.js | 2 +- webpack.config.js | 10 +- 23 files changed, 1195 insertions(+), 613 deletions(-) create mode 100644 composer.json create mode 100644 composer.lock create mode 100644 config/dotenv.php delete mode 100644 config/paths.js delete mode 100644 config/webpack.common.js delete mode 100644 config/webpack.dev.js delete mode 100644 config/webpack.prod.js create mode 100644 config/webpack/paths.js create mode 100644 config/webpack/webpack.common.js create mode 100644 config/webpack/webpack.dev.js create mode 100644 config/webpack/webpack.prod.js delete mode 100644 index.html create mode 100644 index.php delete mode 100644 legal-notice.html create mode 100644 legal-notice.php delete mode 100644 license.html create mode 100644 license.php delete mode 100644 mentions-legales.html create mode 100644 mentions-legales.php diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..44af05a --- /dev/null +++ b/composer.json @@ -0,0 +1,23 @@ +{ + "name": "armandphilippot/demo.armandphilippot.test", + "description": "A collection of small apps demo.", + "license": "MIT", + "authors": [ + { + "name": "Armand Philippot", + "email": "contact@armandphilippot.com", + "homepage": "https://www.armandphilippot.com/" + } + ], + "homepage": "https://demo.armandphilippot.com/", + "scripts": { + "lint": "phpcs --standard=PSR2", + "fix": "phpcbf --standard=PSR2" + }, + "require-dev": { + "squizlabs/php_codesniffer": "^3.6" + }, + "require": { + "vlucas/phpdotenv": "^5.3" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..ed2822a --- /dev/null +++ b/composer.lock @@ -0,0 +1,526 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "f2435682c29a01197ab8727ee125f1ca", + "packages": [ + { + "name": "graham-campbell/result-type", + "version": "v1.0.3", + "source": { + "type": "git", + "url": "https://github.com/GrahamCampbell/Result-Type.git", + "reference": "296c015dc30ec4322168c5ad3ee5cc11dae827ac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/296c015dc30ec4322168c5ad3ee5cc11dae827ac", + "reference": "296c015dc30ec4322168c5ad3ee5cc11dae827ac", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "phpoption/phpoption": "^1.8" + }, + "require-dev": { + "phpunit/phpunit": "^6.5.14 || ^7.5.20 || ^8.5.19 || ^9.5.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "GrahamCampbell\\ResultType\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk" + } + ], + "description": "An Implementation Of The Result Type", + "keywords": [ + "Graham Campbell", + "GrahamCampbell", + "Result Type", + "Result-Type", + "result" + ], + "support": { + "issues": "https://github.com/GrahamCampbell/Result-Type/issues", + "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.0.3" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type", + "type": "tidelift" + } + ], + "time": "2021-10-17T19:48:54+00:00" + }, + { + "name": "phpoption/phpoption", + "version": "1.8.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/php-option.git", + "reference": "5455cb38aed4523f99977c4a12ef19da4bfe2a28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/5455cb38aed4523f99977c4a12ef19da4bfe2a28", + "reference": "5455cb38aed4523f99977c4a12ef19da4bfe2a28", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "phpunit/phpunit": "^6.5.14 || ^7.0.20 || ^8.5.19 || ^9.5.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8-dev" + } + }, + "autoload": { + "psr-4": { + "PhpOption\\": "src/PhpOption/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com" + }, + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk" + } + ], + "description": "Option Type for PHP", + "keywords": [ + "language", + "option", + "php", + "type" + ], + "support": { + "issues": "https://github.com/schmittjoh/php-option/issues", + "source": "https://github.com/schmittjoh/php-option/tree/1.8.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption", + "type": "tidelift" + } + ], + "time": "2021-08-28T21:27:29+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.23.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-02-19T12:13:01+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.23.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6", + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-05-27T12:26:48+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.23.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-07-28T13:41:28+00:00" + }, + { + "name": "vlucas/phpdotenv", + "version": "v5.3.1", + "source": { + "type": "git", + "url": "https://github.com/vlucas/phpdotenv.git", + "reference": "accaddf133651d4b5cf81a119f25296736ffc850" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/accaddf133651d4b5cf81a119f25296736ffc850", + "reference": "accaddf133651d4b5cf81a119f25296736ffc850", + "shasum": "" + }, + "require": { + "ext-pcre": "*", + "graham-campbell/result-type": "^1.0.2", + "php": "^7.1.3 || ^8.0", + "phpoption/phpoption": "^1.8", + "symfony/polyfill-ctype": "^1.23", + "symfony/polyfill-mbstring": "^1.23.1", + "symfony/polyfill-php80": "^1.23.1" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "ext-filter": "*", + "phpunit/phpunit": "^7.5.20 || ^8.5.21 || ^9.5.10" + }, + "suggest": { + "ext-filter": "Required to use the boolean validator." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.3-dev" + } + }, + "autoload": { + "psr-4": { + "Dotenv\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk" + }, + { + "name": "Vance Lucas", + "email": "vance@vancelucas.com" + } + ], + "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", + "keywords": [ + "dotenv", + "env", + "environment" + ], + "support": { + "issues": "https://github.com/vlucas/phpdotenv/issues", + "source": "https://github.com/vlucas/phpdotenv/tree/v5.3.1" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", + "type": "tidelift" + } + ], + "time": "2021-10-02T19:24:42+00:00" + } + ], + "packages-dev": [ + { + "name": "squizlabs/php_codesniffer", + "version": "3.6.1", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "f268ca40d54617c6e06757f83f699775c9b3ff2e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/f268ca40d54617c6e06757f83f699775c9b3ff2e", + "reference": "f268ca40d54617c6e06757f83f699775c9b3ff2e", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, + "time": "2021-10-11T04:00:11+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.1.0" +} diff --git a/config/dotenv.php b/config/dotenv.php new file mode 100644 index 0000000..16d31af --- /dev/null +++ b/config/dotenv.php @@ -0,0 +1,20 @@ +safeLoad(); + $current_env = $_ENV['CURRENT_ENV']; + return $current_env; + } else { + return ''; + } +} diff --git a/config/paths.js b/config/paths.js deleted file mode 100644 index 8b67206..0000000 --- a/config/paths.js +++ /dev/null @@ -1,15 +0,0 @@ -const path = require('path'); - -const devFolder = path.resolve(__dirname, '../src/'); - -module.exports = { - src: { - fonts: path.resolve(devFolder, './fonts/'), - images: path.resolve(devFolder, './images/'), - scripts: path.resolve(devFolder, './js/app.js'), - style: path.resolve(devFolder, './scss/style.scss'), - }, - dist: path.resolve(devFolder, '../assets/'), - files: [path.resolve(devFolder, '../**/*.html')], - sassPaths: [path.resolve(devFolder, '../node_modules/modern-normalize/')], -}; diff --git a/config/webpack.common.js b/config/webpack.common.js deleted file mode 100644 index 69ecd2f..0000000 --- a/config/webpack.common.js +++ /dev/null @@ -1,102 +0,0 @@ -const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin'); -const CopyPlugin = require('copy-webpack-plugin'); -const paths = require('./paths'); - -module.exports = { - entry: { - style: { - import: paths.src.style, - filename: 'js/style.js', - }, - scripts: { - import: paths.src.scripts, - filename: 'js/app.js', - }, - }, - output: { - path: paths.dist, - clean: true, - hotUpdateChunkFilename: 'hmr/[id].[fullhash].hot-update.js', - hotUpdateMainFilename: 'hmr/[runtime].[fullhash].hot-update.json', - }, - module: { - rules: [ - { - test: /\.m?js$/, - exclude: /node_modules/, - use: ['babel-loader'], - }, - { - test: /\.(png|jpe?g|gif|svg)$/i, - type: 'asset/resource', - generator: { - filename: (img) => { - const relativePath = img.filename; - const filteredPath = relativePath.replace('src/', ''); - return filteredPath; - }, - }, - }, - { - test: /\.(woff|woff2|eot|ttf|otf)$/i, - type: 'asset/resource', - generator: { - filename: (font) => { - const relativePath = font.filename; - const filteredPath = relativePath.replace('src/', ''); - return filteredPath; - }, - }, - }, - ], - }, - optimization: { - runtimeChunk: { - name: 'js/runtime', - }, - splitChunks: { - cacheGroups: { - style: { - type: 'css/mini-extract', - name: '/css/style', - chunks: (chunk) => chunk.name === 'style', - enforce: true, - }, - }, - }, - }, - plugins: [ - new ImageMinimizerPlugin({ - minimizerOptions: { - plugins: [ - ['gifsicle', { interlaced: true }], - ['mozjpeg', { progressive: true, quality: 75 }], - ['optipng', { optimizationLevel: 5 }], - [ - 'svgo', - { - plugins: [ - { - name: 'preset-default', - params: { - overrides: { - removeTitle: false, - removeViewBox: false, - }, - }, - }, - 'removeDimensions', - ], - }, - ], - ], - }, - }), - new CopyPlugin({ - patterns: [ - { from: paths.src.fonts, to: 'fonts', noErrorOnMissing: true }, - { from: paths.src.images, to: 'images', noErrorOnMissing: true }, - ], - }), - ], -}; diff --git a/config/webpack.dev.js b/config/webpack.dev.js deleted file mode 100644 index 4ac420c..0000000 --- a/config/webpack.dev.js +++ /dev/null @@ -1,91 +0,0 @@ -const dartSass = require('sass'); -const paths = require('./paths'); -require('dotenv').config(); - -const protocol = process.env.WEBPACK_PROTOCOL; -const host = process.env.WEBPACK_HOST; -const port = process.env.WEBPACK_PORT; -const siteURL = `${protocol}://${host}/`; -const isHttps = protocol === 'https'; -const isHMREnabled = process.env.WEBPACK_HOT_RELOAD === 'true'; -const isOpenBoolean = process.env.WEBPACK_OPEN === 'true' || process.env.WEBPACK_OPEN === 'false'; - -module.exports = { - mode: 'development', - module: { - rules: [ - { - test: /\.(sa|sc|c)ss$/i, - use: [ - 'style-loader', - { - loader: 'css-loader', - options: { - importLoaders: 2, - sourceMap: true, - }, - }, - { - loader: 'postcss-loader', - options: { - postcssOptions: { - plugins: ['autoprefixer'], - }, - sourceMap: true, - }, - }, - { - loader: 'sass-loader', - options: { - implementation: dartSass, - sassOptions: { - indentWidth: 2, - outputStyle: 'expanded', - includePaths: paths.sassPaths, - }, - sourceMap: true, - }, - }, - ], - }, - ], - }, - devServer: { - client: { - overlay: { - warnings: true, - errors: true, - }, - }, - devMiddleware: { - writeToDisk: true, - }, - host, - port, - hot: isHMREnabled, - https: !isHttps - ? false - : { - key: process.env.WEBPACK_HTTPS_KEY, - cert: process.env.WEBPACK_HTTPS_CERT, - }, - liveReload: true, - open: isOpenBoolean - ? process.env.WEBPACK_OPEN - : { - app: { - name: process.env.WEBPACK_OPEN, - }, - }, - proxy: { - '/': { - target: siteURL, - changeOrigin: true, - secure: false, - }, - }, - static: false, - watchFiles: paths.files, - }, - devtool: 'inline-source-map', -}; diff --git a/config/webpack.prod.js b/config/webpack.prod.js deleted file mode 100644 index a2778f5..0000000 --- a/config/webpack.prod.js +++ /dev/null @@ -1,48 +0,0 @@ -const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); -const MiniCssExtractPlugin = require('mini-css-extract-plugin'); -const dartSass = require('sass'); -const paths = require('./paths'); - -module.exports = { - mode: 'production', - devtool: false, - optimization: { - minimizer: [new CssMinimizerPlugin(), '...'], - }, - module: { - rules: [ - { - test: /\.(sa|sc|c)ss$/i, - use: [ - { - loader: MiniCssExtractPlugin.loader, - options: { - publicPath: '../', - }, - }, - 'css-loader', - { - loader: 'postcss-loader', - options: { - postcssOptions: { - plugins: ['autoprefixer'], - }, - }, - }, - { - loader: 'sass-loader', - options: { - implementation: dartSass, - sassOptions: { - indentWidth: 2, - outputStyle: 'compressed', - includePaths: paths.sassPaths, - }, - }, - }, - ], - }, - ], - }, - plugins: [new MiniCssExtractPlugin()], -}; diff --git a/config/webpack/paths.js b/config/webpack/paths.js new file mode 100644 index 0000000..fd4c73f --- /dev/null +++ b/config/webpack/paths.js @@ -0,0 +1,15 @@ +const path = require('path'); + +const devFolder = path.resolve(__dirname, '../../src/'); + +module.exports = { + src: { + fonts: path.resolve(devFolder, './fonts/'), + images: path.resolve(devFolder, './images/'), + scripts: path.resolve(devFolder, './js/app.js'), + style: path.resolve(devFolder, './scss/style.scss'), + }, + dist: path.resolve(devFolder, '../assets/'), + files: [path.resolve(devFolder, '../**/*.php')], + sassPaths: [path.resolve(devFolder, '../node_modules/modern-normalize/')], +}; diff --git a/config/webpack/webpack.common.js b/config/webpack/webpack.common.js new file mode 100644 index 0000000..69ecd2f --- /dev/null +++ b/config/webpack/webpack.common.js @@ -0,0 +1,102 @@ +const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin'); +const CopyPlugin = require('copy-webpack-plugin'); +const paths = require('./paths'); + +module.exports = { + entry: { + style: { + import: paths.src.style, + filename: 'js/style.js', + }, + scripts: { + import: paths.src.scripts, + filename: 'js/app.js', + }, + }, + output: { + path: paths.dist, + clean: true, + hotUpdateChunkFilename: 'hmr/[id].[fullhash].hot-update.js', + hotUpdateMainFilename: 'hmr/[runtime].[fullhash].hot-update.json', + }, + module: { + rules: [ + { + test: /\.m?js$/, + exclude: /node_modules/, + use: ['babel-loader'], + }, + { + test: /\.(png|jpe?g|gif|svg)$/i, + type: 'asset/resource', + generator: { + filename: (img) => { + const relativePath = img.filename; + const filteredPath = relativePath.replace('src/', ''); + return filteredPath; + }, + }, + }, + { + test: /\.(woff|woff2|eot|ttf|otf)$/i, + type: 'asset/resource', + generator: { + filename: (font) => { + const relativePath = font.filename; + const filteredPath = relativePath.replace('src/', ''); + return filteredPath; + }, + }, + }, + ], + }, + optimization: { + runtimeChunk: { + name: 'js/runtime', + }, + splitChunks: { + cacheGroups: { + style: { + type: 'css/mini-extract', + name: '/css/style', + chunks: (chunk) => chunk.name === 'style', + enforce: true, + }, + }, + }, + }, + plugins: [ + new ImageMinimizerPlugin({ + minimizerOptions: { + plugins: [ + ['gifsicle', { interlaced: true }], + ['mozjpeg', { progressive: true, quality: 75 }], + ['optipng', { optimizationLevel: 5 }], + [ + 'svgo', + { + plugins: [ + { + name: 'preset-default', + params: { + overrides: { + removeTitle: false, + removeViewBox: false, + }, + }, + }, + 'removeDimensions', + ], + }, + ], + ], + }, + }), + new CopyPlugin({ + patterns: [ + { from: paths.src.fonts, to: 'fonts', noErrorOnMissing: true }, + { from: paths.src.images, to: 'images', noErrorOnMissing: true }, + ], + }), + ], +}; diff --git a/config/webpack/webpack.dev.js b/config/webpack/webpack.dev.js new file mode 100644 index 0000000..4ac420c --- /dev/null +++ b/config/webpack/webpack.dev.js @@ -0,0 +1,91 @@ +const dartSass = require('sass'); +const paths = require('./paths'); +require('dotenv').config(); + +const protocol = process.env.WEBPACK_PROTOCOL; +const host = process.env.WEBPACK_HOST; +const port = process.env.WEBPACK_PORT; +const siteURL = `${protocol}://${host}/`; +const isHttps = protocol === 'https'; +const isHMREnabled = process.env.WEBPACK_HOT_RELOAD === 'true'; +const isOpenBoolean = process.env.WEBPACK_OPEN === 'true' || process.env.WEBPACK_OPEN === 'false'; + +module.exports = { + mode: 'development', + module: { + rules: [ + { + test: /\.(sa|sc|c)ss$/i, + use: [ + 'style-loader', + { + loader: 'css-loader', + options: { + importLoaders: 2, + sourceMap: true, + }, + }, + { + loader: 'postcss-loader', + options: { + postcssOptions: { + plugins: ['autoprefixer'], + }, + sourceMap: true, + }, + }, + { + loader: 'sass-loader', + options: { + implementation: dartSass, + sassOptions: { + indentWidth: 2, + outputStyle: 'expanded', + includePaths: paths.sassPaths, + }, + sourceMap: true, + }, + }, + ], + }, + ], + }, + devServer: { + client: { + overlay: { + warnings: true, + errors: true, + }, + }, + devMiddleware: { + writeToDisk: true, + }, + host, + port, + hot: isHMREnabled, + https: !isHttps + ? false + : { + key: process.env.WEBPACK_HTTPS_KEY, + cert: process.env.WEBPACK_HTTPS_CERT, + }, + liveReload: true, + open: isOpenBoolean + ? process.env.WEBPACK_OPEN + : { + app: { + name: process.env.WEBPACK_OPEN, + }, + }, + proxy: { + '/': { + target: siteURL, + changeOrigin: true, + secure: false, + }, + }, + static: false, + watchFiles: paths.files, + }, + devtool: 'inline-source-map', +}; diff --git a/config/webpack/webpack.prod.js b/config/webpack/webpack.prod.js new file mode 100644 index 0000000..a2778f5 --- /dev/null +++ b/config/webpack/webpack.prod.js @@ -0,0 +1,48 @@ +const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); +const dartSass = require('sass'); +const paths = require('./paths'); + +module.exports = { + mode: 'production', + devtool: false, + optimization: { + minimizer: [new CssMinimizerPlugin(), '...'], + }, + module: { + rules: [ + { + test: /\.(sa|sc|c)ss$/i, + use: [ + { + loader: MiniCssExtractPlugin.loader, + options: { + publicPath: '../', + }, + }, + 'css-loader', + { + loader: 'postcss-loader', + options: { + postcssOptions: { + plugins: ['autoprefixer'], + }, + }, + }, + { + loader: 'sass-loader', + options: { + implementation: dartSass, + sassOptions: { + indentWidth: 2, + outputStyle: 'compressed', + includePaths: paths.sassPaths, + }, + }, + }, + ], + }, + ], + }, + plugins: [new MiniCssExtractPlugin()], +}; diff --git a/index.html b/index.html deleted file mode 100644 index 47a8592..0000000 --- a/index.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - Demo | Armand Philippot - - - - -
- - -
-
-
- -

- Armand Philippot -

-

Front-end developer

-
- -
-
-
- Select an app inside menu to see a live preview and app details - (description, technologies, repositories). -
- -
- - - - - diff --git a/index.php b/index.php new file mode 100644 index 0000000..d0b2f7c --- /dev/null +++ b/index.php @@ -0,0 +1,80 @@ + + + + + + + + + Demo | Armand Philippot + '; + } + ?> + + + +
+ + +
+
+
+ +

+ Armand Philippot +

+

Front-end developer

+
+ +
+
+
+ Select an app inside menu to see a live preview and app details + (description, technologies, repositories). +
+ +
+ + + + + + diff --git a/legal-notice.html b/legal-notice.html deleted file mode 100644 index 7b6c2bc..0000000 --- a/legal-notice.html +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - Legal Notice | Demo | Armand Philippot - - - - -
- - -
-
-
- -

- Armand Philippot -

-

Front-end developer

-
- -
-
- -
- - - - - diff --git a/legal-notice.php b/legal-notice.php new file mode 100644 index 0000000..67a1ade --- /dev/null +++ b/legal-notice.php @@ -0,0 +1,93 @@ + + + + + + + + + Legal Notice | Demo | Armand Philippot + '; + } + ?> + + + +
+ + +
+
+
+ +

+ Armand Philippot +

+

Front-end developer

+
+ +
+
+ +
+ + + + + + diff --git a/license.html b/license.html deleted file mode 100644 index 15ea458..0000000 --- a/license.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - License | Demo | Armand Philippot - - - - -
- - -
-
-
- -

- Armand Philippot -

-

Front-end developer

-
- -
-
- -
- - - - - diff --git a/license.php b/license.php new file mode 100644 index 0000000..402c696 --- /dev/null +++ b/license.php @@ -0,0 +1,96 @@ + + + + + + + + + License | Demo | Armand Philippot + '; + } + ?> + + + +
+ + +
+
+
+ +

+ Armand Philippot +

+

Front-end developer

+
+ +
+
+ +
+ + + + + + diff --git a/mentions-legales.html b/mentions-legales.html deleted file mode 100644 index ebfdf52..0000000 --- a/mentions-legales.html +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - Mentions légales | Demo | Armand Philippot - - - - -
- - -
-
-
- -

- Armand Philippot -

-

Front-end developer

-
- -
-
- -
- - - - - diff --git a/mentions-legales.php b/mentions-legales.php new file mode 100644 index 0000000..e42f363 --- /dev/null +++ b/mentions-legales.php @@ -0,0 +1,93 @@ + + + + + + + + + Mentions légales | Demo | Armand Philippot + '; + } + ?> + + + +
+ + +
+
+
+ +

+ Armand Philippot +

+

Front-end developer

+
+ +
+
+ +
+ + + + + + diff --git a/package.json b/package.json index b9f77f5..7048257 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "fix:scss": "stylelint \"**/*.scss\" --fix", "lint": "npm-run-all --parallel lint:*", "lint:js": "eslint --ext .js,.jsx", + "lint:php": "composer lint", "lint:scss": "stylelint \"**/*.scss\" --syntax scss --formatter verbose", "release": "standard-version -s", "rtl": "rtlcss assets/css/style.css assets/css/style-rtl.css", diff --git a/src/js/i18n/locales/en.js b/src/js/i18n/locales/en.js index 9717528..a24b944 100644 --- a/src/js/i18n/locales/en.js +++ b/src/js/i18n/locales/en.js @@ -27,7 +27,7 @@ const en = { footer: { legalNotice: { txt: 'Legal notice', - link: 'legal-notice.html', + link: 'legal-notice.php', }, license: 'License MIT', }, diff --git a/src/js/i18n/locales/fr.js b/src/js/i18n/locales/fr.js index 9c93012..401f297 100644 --- a/src/js/i18n/locales/fr.js +++ b/src/js/i18n/locales/fr.js @@ -27,7 +27,7 @@ const fr = { footer: { legalNotice: { txt: 'Mentions légales', - link: 'mentions-legales.html', + link: 'mentions-legales.php', }, license: 'Licence MIT', }, diff --git a/webpack.config.js b/webpack.config.js index 44379a1..734cc5a 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,9 +1,9 @@ -const { merge } = require("webpack-merge"); -const common = require("./config/webpack.common"); -const dev = require("./config/webpack.dev"); -const prod = require("./config/webpack.prod"); +const { merge } = require('webpack-merge'); +const common = require('./config/webpack/webpack.common'); +const dev = require('./config/webpack/webpack.dev'); +const prod = require('./config/webpack/webpack.prod'); -const isProduction = process.env.NODE_ENV === "production"; +const isProduction = process.env.NODE_ENV === 'production'; module.exports = () => { if (isProduction) return merge(common, prod); -- cgit v1.2.3