@acanto/laravel-scripts

Scripts to manage Laravel Frontend applications

Usage no npm install needed!

<script type="module">
  import acantoLaravelScripts from 'https://cdn.skypack.dev/@acanto/laravel-scripts';
</script>

README

Laravel Scripts

npm (scoped)

For all the documentation refer to the Acanto Framework Docs

Installation

It is recomended to start a project by running:

npx @acanto/create-laravel-app myproject
cd myproject
npm start

Available commands

From your root folder run npx acanto help or npm run help to view the available commands and their description.

Development

TODO

  • [] Environments might be made configurable through a custom config.environments value in the package.json, where each key is the environment name and the value is its branch, the default values would be:
  "config": {
    "environments": {
      "dev": "master",
      "staging": "staging",
      "production": "production"
    },
  • Run php artisan view:clear && composer dump after generate component and after core (not needed with ps-4 autoloading mechanism)
  • [] autogenerate dummy translations.csv files based on cms api response in case they miss
  • [] check should check that there is a /vendor folder, otherwise run composer install
  • [] Add this command somewhere to the end of your deploy script (I put it just after artisan up) php artisan opcache:clear source
  • [] Implement preload/prefetch, see article from webpack author and probably use preload-webpack-plugin.

Notes

About assets inlining, CSS is inlined if the file size is minor than 50kb, as the AMP specification suggest. JS inline threshold is set to just 2kb instead, see this article.

About optimization evaluate the use of compression-webpack-plugin

About gzip compression see October's not-including-it-by-default reasons here https://github.com/octobercms/october/pull/1896, https://github.com/octobercms/october/pull/1885, https://github.com/octobercms/library/pull/201/commits/db2dec55ed7d42201f92b59e1de74b5c3196841c, https://github.com/octobercms/october/pull/1885/commits/86ca0c7e8d79a4a8f0662203b0b04cf549b6fc63, https://github.com/octobercms/october/issues/1847, https://octobercms.com/forum/post/assets-gzip-compression

About polyfills babel and webpack see: https://github.com/babel/babel-loader#note-transform-runtime--custom-polyfills-eg-promise-library, https://github.com/zloirock/core-js#babel, https://babeljs.io/docs/en/next/babel-preset-env.html#how-does-it-work, https://www.npmjs.com/package/polyfill-library

Bash utilities

  • Run start with more RAM node --max_old_space_size=8192 node_modules/@acanto/laravel-scripts/bin/laravel-scripts.js start (@see similar issue)

.htaccess

For a good explanation on how to manage redirects SEO friendly see How to force https, www and a trailing slash with one redirect.