ctf0 / laravel-mix-versionhash

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

Wrong filename in key `mix-manifest.json` #44

Closed KerberosMorphy closed 5 months ago

KerberosMorphy commented 3 years ago

Hi there,

I'm trying to use this plugin with webpack to generate a mix-manifest.json file but I don't understand why the filename in the key doesn't match the real filename.

My webpack.config.js :

module.exports = {
    entry: [
        './Scripts/app.js',
    ],
    output: {
        path: path.resolve(__dirname, 'Public'),
        filename: 'js/app.js?id=[chunkhash]',
    },
    resolve: {
        fallback: {
            "stream": require.resolve("stream-browserify")
        }
    },
    devtool: process.env.NODE_ENV !== 'production' ? 'eval-source-map' : false,
    module: {
        rules: [
            {
                test: /\.s[ac]ss$/i,
                use: [
                    {
                        loader: MiniCssExtractPlugin.loader,
                        options: {}
                    },
                    {
                        loader: "css-loader",
                        options: {
                            url: false
                        }
                    },
                    {
                        loader: 'sass-loader',
                        options: {
                            webpackImporter: false,
                            sassOptions: {
                                outputStyle: "compressed",
                            },
                        },
                    }
                ],
            },
        ],
    },
    optimization: {
        minimize: true,
        minimizer: [new TerserPlugin()],
    },
    plugins: [
        new MiniCssExtractPlugin({
            filename: 'css/app.css?id=[chunkhash]',
        }),
        new WebpackLaravelMixManifest()
    ],
};

The generated file:

Public/
├── css/
│   └── app.css
├── js/
│   └── app.js
└── mix-manifest.json

The mix-manifest.json generated:

{
  "/css/main.css": "/css/app.css?id=2957c3d783357f8cddbe",
  "/js/main.js": "/js/app.js?id=2957c3d783357f8cddbe"
}

What it should be:

{
  "/css/app.css": "/css/app.css?id=2957c3d783357f8cddbe",
  "/js/app.js": "/js/app.js?id=2957c3d783357f8cddbe"
}