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.

Adding Files to mix-manifes.json, Versioning Extra Files

See original GitHub issue
  • Laravel Mix Version: 0.8.3
  • Node Version (node -v): 7.5.0
  • NPM Version (npm -v): 4.1.2
  • OS: MacOS 10.12.3

I’d like to call some JS and CSS on only on a few specific pages. I’m achieve this by using Blade @stack() and @push(), however, simply using copy() does not add these files to mix-manifes.json. This causes Laravel to throw an error when adding the files via {{ mix('myFile.ext') }}. (I guess I could not use mix(), but I feel like I should be.)

The only way I have found to add these files to mix-manifes.json is to version them. Is there another way to tell Mix to add files to the manifest?

This process lead me to the compile error below… am I doing something incorrect?

Description:

Versioning copied extra files throws an error when having a clean public folder. Error does not occur if the file exists from a previous non-versioned build.

mix.js('resources/assets/js/wfl.js', 'public/js')
   .extract(['fluidvids.js', 'jquery', 'vue'])

   .copy('node_modules/flatpickr/dist/flatpickr.js', 'public/js')
   .copy('node_modules/flatpickr/dist/flatpickr.css', 'public/css')

   .copy('node_modules/slick-carousel/slick/slick.js', 'public/js')
   .copy('node_modules/slick-carousel/slick/slick.css', 'public/css')

   .sass('resources/assets/sass/wfl.scss', 'public/css')

   .copy('resources/assets/fonts', 'public/fonts', false)
   .copy('resources/assets/images', 'public/images', false)

   .sourceMaps()
   .version(['public/css/flatpickr.css', 'public/js/flatpickr.js', 'public/css/slick.css', 'public/js/slick.js']);

Steps To Reproduce:

  1. have a clean public directory
  2. copy a css or js file to your public directory via copy()
  3. version that file

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
JeffreyWaycommented, Feb 23, 2017

I’m pushing an update to allow you to do this.

0reactions
danremollinocommented, Feb 24, 2017

Hey @JeffreyWay, this is working great, thanks!

The workflow seems to copy the file to the destination as specified in your webpack.mix.js and then make a copy of that file to version it, leaving two files in the target directory. Would it be possible to have it trash the unhashed file at build?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding Files to mix-manifes.json, Versioning Extra Files #451
The only way I have found to add these files to mix-manifes.json is to version them. Is there another way to tell Mix...
Read more >
Versioning | Laravel Mix Documentation
Version compiled assets AND public/js/file.js ... Laravel Mix's generated mix-manifest.json file, extract the asset file names, and then generate your HTML.
Read more >
File name versioning of static assets using Laravel Mix
First, we're going to use Mix's version function which will populate a mix-manifest.json file with something that looks like this:.
Read more >
Versioning with Mix, manifest does not exist. {but.... it does!)
json, so i changed it to what it was asking for 'manifest.json'. So I ran npm run production and... now It says; Unable...
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 >

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