-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Asset Build Tool #17262
base: main
Are you sure you want to change the base?
New Asset Build Tool #17262
Conversation
# Conflicts: # src/OrchardCore.Modules/OrchardCore.AdminDashboard/Assets.json # src/OrchardCore.Modules/OrchardCore.AdminMenu/Assets.json # src/OrchardCore.Modules/OrchardCore.AdminMenu/wwwroot/Scripts/admin-menu-icon-picker.js # src/OrchardCore.Modules/OrchardCore.Media/ResourceManifestOptionsConfiguration.cs # src/OrchardCore.Modules/OrchardCore.Resources/package.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/OrchardCore.Modules/OrchardCore.AdminDashboard/Assets2.json
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.AdminDashboard/Assets2.json
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.AdminMenu/Views/Menu/List.cshtml
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.AdminMenu/package-lock.json
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Flows/wwwroot/Scripts/flows.edit.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Zoltán Lehóczky <[email protected]>
…MS/OrchardCore into skrypt/asset-build-tool
This pull request has merge conflicts. Please resolve those before requesting a review. |
# Conflicts: # src/OrchardCore.Modules/OrchardCore.Cors/wwwroot/Scripts/cors-admin.js # src/OrchardCore.Modules/OrchardCore.Cors/wwwroot/Scripts/cors-admin.min.js # src/OrchardCore.Modules/OrchardCore.Media/ResourceManifestOptionsConfiguration.cs # src/OrchardCore.Modules/OrchardCore.Media/wwwroot/Scripts/media.min.js
src/OrchardCore.Modules/OrchardCore.Media/Views/Admin/MediaApplication.cshtml
Show resolved
Hide resolved
Modules and Themes root folder should not be used for package.json files
@sebastienros answers from last meeting. Why not using Parcel for transpiling SASS assets? The reason is that Parcel is built so that it can compile assets either in "Production" or "Development" mode by either setting an environment variable or by passing it through API config. When in "Development" mode ; doing "yarn watch" will create the minified .css file and .map file for debugging purposes. Though, when doing "yarn build" in "Production" mode "as it will do on CI", it will create the minified .css file only. Now, since in OC we always transpile both .css and .min.css files I had no choice to create a custom action for it. More on that on side thoughts. Also, it was easier for me to create a SASS action that actually uses the same library than Parcel uses internally (lightningcss). The only thing that was missing is a watcher. I added chokidar so that it watches at the file built and also parsing that file for import paths to add watchers on these too. I did not made it recursive yet though ; but it works pretty well so far. Also, Parcel optimizes .js files by obfuscating it at the same time making smaller sized files. Side thoughtsFrom what I understand, there is no need to provide the unminified asset in production unless you would want to debug it. But it is then equivalent than providing the .map file with the minified .css file. So while our ResourceManager and StyleTagHelper allows to provide an asp-src and debug-src attribute I wanted to have both. Maybe, future enhancement would be to simply always compile the minified asset and provide better configurations for .map files. So, also, Parcel reacts differently as it is a bundler. If you import a .scss file inside a .ts file for example ; it will create both a .js and .css file when building. |
Some extra work for me on Christmas holidays.🎅🏼
Assets Build Tool
Created by @jptissot
Based on Concurrently and Parcel but can also run Vite (experimental) and probably Webpack too (untested). This is a non-opiniated build tool which allows to be extended for any asset compiler/bundler that someone may require.
This build tool essentially uses
Concurrently
instead ofGulp
.Concurrently
, is a concurrent shell runner which allows to trigger any possible shell command. It allows to triggerParcel
,Vite
,Gulp
or any other command that we need for building assets. Everything is written as ES6 modules (.mjs files).Kind of needed for Vue 3 migration because it needs to use either
Vite
orParcel
to build as ES6 modules.Old assets are not compiled as ES6 modules so they don't need these bundlers. For that matter I kept the old gulpfile.js which will be now triggered by
Concurrently
.What needs to be done over time is to migrate these javascript files to ES6 modules (.mjs files or .ts files) so that we can compile them as modules. But that's a migration that will happen over time.
Features
yarn build
yarn build -n module-name
yarn watch -n module-name
. "parcel" and "sass" actions only.yarn build -g
yarn build -gr
Update
Finally, I'm keeping the old gulp pipeline because there is nothing wrong with it. Also, for backward compatibility with older modules that requires it. I'm using
GulpAssets.json
for the Gulp build tool and usingAssets.json
for the new one. This way, no need to migrate to the new build tool. I'm simply triggeringgulp rebuild
withConcurrently
in the new asset build tool. Because that's what it is essentially, a concurrent shell runner. This way, it is going to be a softer migration for those who already have modules that are built with the old gulp pipeline.Of course, this PR needs to be accepted by community first.
TODO
Modules to migrate:
@jptissot @deanmarcussen @aderderian
Fixes #14169. Related to #15740.