question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Version only specific files

See original GitHub issue
  • Laravel Mix Version: 0.8.7
  • Node Version 7.6.0
  • NPM Version 4.1.2
  • OS: macOS Sierra 10.12.3

Description:

I want to version only selected pieces in my webpack-mix

Steps To Reproduce:

npm run dev

with this in my webpack-mix file

const { mix } = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.sass('resources/assets/sass/frontend/app.scss', 'public/css/frontend/dist/frontend.css');
mix.sass('resources/assets/sass/backend/app.scss', 'public/css/backend/dist/backend.css');

mix.combine([
    'public/css/frontend/dist/frontend.css',
    'resources/assets/css/plugin/bootstrap-select/bootstrap-select.min.css'
], 'public/css/frontend/frontend.css');

mix.combine([
    'public/css/backend/dist/backend.css',
    'resources/assets/css/plugin/bootstrap-select/bootstrap-select.min.css'
], 'public/css/backend/backend.css');

mix.js('resources/assets/js/backend/customers/customers.js', 'public/js/backend/customers/customers.js');

mix.js([
        'resources/assets/js/frontend/app.js',
        'resources/assets/js/plugin/sweetalert/sweetalert.min.js',
        'resources/assets/js/plugins.js'
    ], 'public/js/frontend/frontend.js');
mix.js([
        'resources/assets/js/backend/app.js',
        'resources/assets/js/plugin/bootstrap-select/bootstrap-select.min.js',
        'resources/assets/js/plugin/sweetalert/sweetalert.min.js',
        'resources/assets/js/plugins.js'
    ], 'public/js/backend/backend.js');

work fine but i want to ad .version() to all five final files except the css files created in sassing cause then the css combine fails.

I also tryed to specify the files that i want to version but they cant be found.

Thank you JW

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
Konstantinacccommented, Oct 10, 2017

Just wondering if I can use mix.version() to version only specific files and not all files generated. To be more specific, I just want to version app.min.js file, so I added mix.version(['public/js/app.min.js']); to my webpack.mix.js

const { mix } = require('laravel-mix');
mix.sass('resources/assets/sass/blade_custom.scss', 'sass/blade-custom.css').styles([ 
    'resources/assets/css/separate/vendor/pnotify.min.css',
    'resources/assets/css/lib/jqueryui/jquery-ui.min.css',
    'resources/assets/css/separate/pages/login.css',
    'resources/assets/css/lib/font-awesome/font-awesome.css',
    'resources/assets/css/lib/bootstrap/bootstrap.css',
    'resources/assets/css/separate/vendor/bootstrap.css
    ], 'public/css/app.css');
mix.scripts([
        'resources/assets/js/lib/jquery/jquery.min.js',
        'resources/assets/js/lib/bootstrap-table/jquery-ui.js',
        'resources/assets/js/plugins.js',
        'resources/assets/js/lib/bootstrap/bootstrap.js',
        'resources/assets/js/chat.js'
    ], 'public/js/app.js');
mix.minify('public/js/app.js');
mix.version(['public/js/app.min.js']);

but instead of getting versioned only app.min.js both app.min.js and app.css get versioned.

2reactions
JeffreyWaycommented, Feb 28, 2017

If you call mix.version(), it should create hashed versions of:

  • public/css/frontend/dist/frontend.css
  • public/css/backend/dist/backend.css
  • public/js/backend/customers/customers.js
  • public/js/frontend/frontend.js
  • public/js/backend/backend.js

You can optionally pass an array to version additional files on top of that.

mix.version([
   'version/this/file/path/too.css'
]);

work fine but i want to ad .version() to all five final files except the css files created in sassing cause then the css combine fails.

That’s because the files you’re referencing in mix.combine() don’t exist. public/css/frontend/dist/frontend.css will actually be something like public/css/frontend/dist/frontend.asdfasdgasdgsad.css. Use a star instead.

mix.combine([
    'public/css/frontend/dist/frontend.*.css',
    'resources/assets/css/plugin/bootstrap-select/bootstrap-select.min.css'
], 'public/css/frontend/frontend.css');
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to track only specific files on a git branch automatically
It doesn't matter if you do maintain branch-specific versions by hand, it still wont' help. Ignore rules do exactly one thing: They keep ......
Read more >
Version only specific files · Issue #472 · laravel-mix ... - GitHub
js'); work fine but i want to ad . version() to all five final files except the css files created in sassing cause...
Read more >
Can I version specific file in Laravel mix? - Laracasts
The current mix version() function version all compiled files. However I don't want some of the compiled files to be versioned. Can I...
Read more >
git-diff Documentation - Git
Select only files that are Added ( A ), Copied ( C ), Deleted ( D ), Modified ... Compare the working tree...
Read more >
Restore a previous version of a file stored in OneDrive
Select the file that you want to restore to an earlier version (you can only restore one file at a time), right-click, then...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found