v1.0.0
版本发布时间: 2017-06-20 04:18:34
laravel-mix/laravel-mix最新发布版本:v6.0.0(2020-12-22 04:31:52)
After countless improvements and bug fixes, the Mix API is now locked and we're ready for a 1.0 release.
Additions
- Bumped Mix to webpack 3, and enabled Scope Hoisting.
- Much of Mix's internal structure has been simplified and refactored to a plugin-based system.
- All non-webpack tasks are now triggered sequentially once webpack finishes its core compile. This means that Mix now supports step-by-step post-build steps. "Copy this here, and then combine those files there, and then minify that concatenated file."
// Compile my JS and apply versioning.
// Then copy the output file to a new directory.
// Then combine these files.
mix.js('resources/assets/js/app.js', 'public/js')
.copy('public/js/app.js', 'public/somewhere')
.combine([
'public/js/vendor/jquery.js',
'public/somewhere/app.js'
], 'public/all.js')
.version();
- The terminal compile output will now better reflect all files that are being processed.
- File versioning has been simplified. When using
mix.version()
, no longer will we version the file name, itself. Instead, we'll generate an md5 of the file's contents, and apply it as a query string to the generatedmix-manifest.json
file. If using a service like Cloudflare, please ensure that you've enabled querystring-based cache-busting. - You may also version any isolated files that aren't part of your main Mix build.
// Version the compiled JS and Sass, but also file.js.
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css')
.version(['public/some/file.js']);
Breaking
Because we're bumping to an official 1.0 release, now is a good time to make a few tiny breaking changes. Don't worry, you can patch these up in seconds.
- Mix now constructs its webpack configuration file behind the scenes. As such, you shouldn't maintain your own
webpack.config.js
file in your project root. Instead, usemix.webpackConfig()
for any custom overrides. - To check for a production environment, instead of
mix.config.inProduction
, domix.inProduction()
. -
cross-env
has been removed as a dependency of Mix. It doesn't make sense for us to maintain it. Frameworks like Laravel will already pull incross-env
, but for your personal projects, either open yourpackage.json
file and remove thecross-env
path from all of your npm scripts, or donpm install cross-env
. - Much of Mix's internal structure has changed. If you were referencing any underlying Mix files or objects, beyond the main public API, please take note. It's possible that you were referencing a Mix configuration item or option. Instead, you may now reference the global
Config
object within yourwebpack.mix.js
file, like so:
Config.sourcemaps; // false
Config.hmr; // false
Config.notifications; // true
-
mix.minify()
no longer overwrites the current file. Instead, it creates a*.min.js
file alongside the original.
Fixes
- If you create a .babelrc file in your project root, it'll now be intelligently merged with Mix's own Babel config file, rather than overwriting it completely. This was the source of many issues in the past.
- When using
mix.copy()
, we now determine the output structure properly. If the first argument tomix.copy()
is a folder, then we'll copy its structure recursively to your destination. If you instead pass an array or regular expression as the first argument, all matched files will be dumped in the top level of your output path. - Many of Mix's internal dependencies are now installed on demand. This way, if you don't plan on using Less or Browsersync, you don't have to worry about those being pulled in.