ctf0 / laravel-mix-versionhash

Auto append hash to file instead of using virtual one
MIT License
61 stars 18 forks source link

Add hash to extracted CSS files #2

Closed jellycode closed 6 years ago

jellycode commented 6 years ago

Check each instance of ExtractTextPlugin and change the filename attribute to a contenthash hashed name. Contenthash is used for CSS files in ExtractTextPlugin.

ctf0 commented 6 years ago

btw aint there away to directly use ExtractTextPlugin ?

new ExtractTextPlugin("[name]-[contenthash].css"),

same as we do with js aka without a loop

jellycode commented 6 years ago

I did tried a few ways, saw the webpackPlugins function and tried to add it there, but it seems mix adds in a ExtractTextPlugin and Vue will add one as well, and when I add one there are three in there...couldn't figure out how to tell it to use my new one with the updated filename setting instead of one of the other two. I think the 'proper' way to do it would be to add a new ExtractTextPlugin with the new settings and force mix to use it, just wasn't sure how?

jellycode commented 6 years ago

Great work by the way, this is a great start!

ctf0 commented 6 years ago

okay, np, thanx for ur help :+1:

ctf0 commented 6 years ago

i've just tested the new logic for css and there are a couple of issues

jellycode commented 6 years ago

Ok, here is my webpack.mix.js

require('laravel-mix-versionhash');
let mix = require('laravel-mix');
if (mix.inProduction()) {
  mix.versionHash();
}
if (!Mix.isUsing('hmr')) {
  mix.sass('resources/assets/sass/app.scss', 'public/css');
}
mix
  .js('resources/assets/js/app.js', 'public/js').extract(['vue']);

I'm using laravel-mix@2.1.11

ctf0 commented 6 years ago

am using same version for mix but different output path for assets public/assets/...

jellycode commented 6 years ago

I see the issue now, working on it...