Migrating build process from laravel-mix to wp-scripts#341
Migrating build process from laravel-mix to wp-scripts#341sabbir1991 wants to merge 4 commits intodevelopfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Migrates the plugin’s non-block asset pipeline from laravel-mix to @wordpress/scripts (wp-scripts) to address dependency/security issues (Issue #330) while keeping the existing block build workflow.
Changes:
- Replaced
laravel-mixbuild steps with a customwebpack.assets.config.jsbased on@wordpress/scripts. - Updated PHP asset registration/enqueue logic and related unit tests to match new generated asset filenames/paths.
- Removed
laravel-mix/cross-envdependencies and updated npm scripts accordingly.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
webpack.mix.js |
Removes the old Laravel Mix build configuration. |
webpack.assets.config.js |
Adds wp-scripts-based webpack config for non-block JS/CSS outputs. |
assets/src/js/login.js |
Imports SCSS so wp-scripts generates the corresponding CSS during bundling. |
src/Modules/Assets.php |
Updates registered stylesheet path to the new wp-scripts-generated CSS filename/location. |
src/Modules/OneTapLogin.php |
Switches OneTap script URL to the new (non-.min) build output name. |
tests/php/Unit/Modules/AssetsTest.php |
Updates expectations for the new CSS path/media argument. |
package.json |
Updates build/watch scripts to use wp-scripts for both assets and blocks; removes Mix deps. |
package-lock.json |
Reflects dependency graph changes after removing Mix/cross-env and updating scripts. |
Comments suppressed due to low confidence (1)
src/Modules/OneTapLogin.php:157
filemtime()is called directly onassets/build/js/onetap.jsfor the script version. If the built asset is missing (e.g., dev install without running the build, or a packaging mistake), this will emit a PHP warning. Consider guarding withfile_exists()(or reusing the Assets module’s safe version resolution approach) and falling back to a stable plugin version when the file is absent.
trailingslashit( plugin()->url ) . 'assets/build/js/onetap.js',
[
'wp-i18n',
],
filemtime( trailingslashit( plugin()->path ) . 'assets/build/js/onetap.js' ),
true
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
webpack.assets.config.js
Outdated
| ...( defaultConfig.output || {} ), | ||
| path: path.resolve( __dirname, 'assets/build/js' ), | ||
| filename: '[name].js', | ||
| clean: false, |
There was a problem hiding this comment.
output.clean is explicitly disabled. This can leave stale JS/CSS/asset-module outputs in assets/build/js across builds (especially if chunking or asset filenames change), which can make debugging harder and potentially ship outdated artifacts. If this directory is dedicated to these assets, consider enabling cleaning (or removing this override) and/or ensuring other build outputs go to separate directories.
| clean: false, | |
| clean: true, |
|
Hello @sabbir1991 I think we should keep the file structure as it was earlier, having the css files inside the Thanks 🙌 |
|
I didn't change the CSS build path. Since it doesn't affect any improvement. I just reduced the complexity from the webpack.assets.config.js file and keep simple build process as like gutenberg block. If we want we can do that later as well |
src/Modules/Assets.php
Outdated
| */ | ||
| public function register_login_styles(): void { | ||
| $this->register_style( self::LOGIN_BUTTON_STYLE_HANDLE, 'build/css/button/style.css' ); | ||
| $this->register_style( self::LOGIN_BUTTON_STYLE_HANDLE, 'build/js/style-login.css' ); |
https://github.com/rtCamp/login-with-google/pull/341/changes#r2905350393 This is what I was talking about |
Related issue: #330