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.

modify mix-manifest.json before complete versioning on production

See original GitHub issue
  • Laravel Mix Version: 0.11.4 (npm list --depth=0)
  • Node Version 6.10.1
  • NPM Version 3.10.10
  • OS: macOS Sierra (10.12.3)

# Description: I have a lot of JS scripts that should be compiled as CSS too. All the time that we’re using laravel-mix in dev environment no problem at all. But, when we launch the application and run the npm run production we found something:

Laravel:

Unable to locate Mix file: /css/all.css. Please check your webpack.mix.js output paths and try again.

The error persists until the command npm run production displays the output after the compilation.

Even with the message DONE Compiled successfully displayed in the console, Laravel was unable to locate the files generated (because they do not exists in the mix-manifest.json yet).

But, when the npm run production was finished and displays the output:

Asset Size Chunks Chunk Names /js/app.b6aa74e460981f1fae55.js 456 kB 0 [emitted] [big] /js/app /css/app.206b204034a2b86d253b760ed61af160.css 84 bytes 0 [emitted] /js/app mix-manifest.json 120 bytes [emitted]

The error was gone and laravel can find the files.

# Steps To Reproduce:

To reproduce follow the steps:

  1. In one terminal tail the mix-manifest.json file running: tail -f mix-manifest.json and let this terminal open

  2. Open another terminal and run the command npm run production and put the other terminal in parallel to look the file (mix-manifest.json) changes in real-time

  3. In my example, the script remove two parameters and only insert them after the command npm run production displays the output.

webpack.mix.js:

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

mix.combine([

 'resources/assets/template/js/core/libraries/jquery.min.js',
    'resources/assets/template/js/core/libraries/jquery.unserialize.js',
    'resources/assets/template/js/core/libraries/bootstrap.min.js',
    'resources/assets/template/js/plugins/loaders/blockui.min.js',
    'resources/assets/libs/jszip-utils.js',
    'resources/assets/libs/FileSaver.js',

    'resources/assets/template/js/core/libraries/jquery_ui/core.min.js',
    'resources/assets/template/js/core/libraries/jquery_ui/effects.min.js',
    'resources/assets/template/js/core/libraries/jquery_ui/interactions.min.js',

    'resources/assets/template/js/plugins/tables/datatables/datatables.min.js',
    'resources/assets/template/js/plugins/tables/datatables/extensions/col_reorder.min.js',
    'resources/assets/template/js/plugins/tables/datatables/extensions/pdfmake/pdfmake.min.js',
    'resources/assets/template/js/plugins/tables/datatables/extensions/jszip/jszip.min.js',
    'resources/assets/template/js/plugins/tables/datatables/extensions/pdfmake/vfs_fonts.min.js',
    'resources/assets/template/js/plugins/tables/datatables/extensions/buttons.min.js',

    'resources/assets/libs/mask.js',
    'resources/assets/libs/mask.money.js',

    'resources/assets/template/js/plugins/ui/prism.min.js',
    'resources/assets/template/js/plugins/ui/headroom/headroom.min.js',
    'resources/assets/template/js/plugins/ui/headroom/headroom_jquery.min.js',
    'resources/assets/template/js/core/app.js',
    'resources/assets/template/js/pages/navbar_hideable.js',
    'resources/assets/template/js/core/libraries/jquery_ui/interactions.min.js',
    'resources/assets/template/js/plugins/forms/selects/select2.min.js',
    'resources/assets/template/js/plugins/forms/selects/select2.pt-BR.js',
    'resources/assets/template/js/plugins/forms/styling/switch.min.js',
    'resources/assets/template/js/plugins/notifications/pnotify.min.js',

    'resources/assets/template/js/plugins/ui/moment/moment.min.js',
    'resources/assets/template/js/plugins/ui/moment/moment_locales.min.js',
    'resources/assets/template/js/plugins/pickers/daterangepicker.js',
    'resources/assets/template/js/plugins/pickers/jquery.datetimepicker.full.min.js',
    'resources/assets/template/js/plugins/uploaders/fileinput.min.js',
    'resources/assets/template/js/plugins/visualization/echarts/echarts.js',

    'resources/assets/template/js/plugins/export/jquery.base64.js',
    'resources/assets/template/js/plugins/export/tableExport.js',
    'resources/assets/template/js/plugins/export/jspdf/libs/sprintf.js',
    'resources/assets/template/js/plugins/export/jspdf/jspdf.js',
    'resources/assets/template/js/plugins/export/jspdf/libs/base64.js',

    'resources/assets/template/js/plugins/trees/jquery.fancytree.js',
    'resources/assets/template/js/plugins/sweetalert.min.js',
    'resources/assets/template/js/plugins/jquery.fileDownload.js',
    'resources/assets/libs/jquery.print.js'

], 'public/js/vendor.js');

mix.combine([
    'resources/assets/css/datatables.css',
    'resources/assets/css/sweetalert.css',
    'resources/assets/css/jquery.datetimepicker.min.css'
], 'public/css/all.css');

mix.js('resources/assets/js/app.js', 'public/js')
    .sass('resources/assets/sass/app.scss', 'public/css');

mix.autoload({
    jquery: ['$', 'window.jQuery']
});

if (mix.config.inProduction) {
    mix.version();
}`

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:19 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
dbpolitocommented, Sep 20, 2017

My fix for this issue was:

webpack.mix.js

// beginning of the file
let fs = require('fs');

Mix.manifest.name = 'mix-manifest-new.json';

// end of the file
mix.then(function () {
    fs.renameSync('./public/mix-manifest-new.json', './public/mix-manifest.json')
})
1reaction
dbpolitocommented, Sep 12, 2017

I’m seeing this problem too on latest laravel-mix

I also see it updates the mix-manifest.json twice, in my case first it generates a mix only with js and scss tasks, and then it generates the complete one with the combine and copy.

In my case this time window means +10 seconds, which basically shows this error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

modify mix-manifest.json before complete versioning on ...
mix.js output paths and try again. The error persists until the command npm run production displays the output after the compilation. Even with ......
Read more >
Versioning | Laravel Mix Documentation
Return to mix-manifest.json and you'll notice that, for each change, the unique hash changes. Importing Versioned Files. This all ...
Read more >
how to use mix versioning in Laravel? - Stack Overflow
Mix.manifest.json is where Laravel looks to get the version number. You will also have to change how you grab your css and js...
Read more >
File name versioning of static assets using Laravel Mix
The process. First, we're going to use Mix's version function which will populate a mix-manifest.json file with something that ...
Read more >
Compiling Assets (Mix) - The PHP Framework For Web Artisans
When you run the dev or production scripts, all of your application's CSS and JavaScript assets will be compiled and placed in your...
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