shellscape / webpack-manifest-plugin

webpack plugin for generating asset manifests
MIT License
1.44k stars 184 forks source link

[bug] filename not contain prefix of output.filename #94

Closed lichnow closed 6 years ago

lichnow commented 6 years ago

My webpack js output config

output: {
    filename: 'js/[name].js'
},

and extracttext plugin

new ExtractTextPlugin({
        filename: 'css/[name].css'
})

but manifest.json

"main.css": "css/main.css",
  "main.js": "js/main.js",
  "manifest.js": "js/manifest.js",
  "vendor.js": "js/vendor.js"

the right manifest.json content should be

"css/main.css": "css/main.css",
  "js/main.js": "js/main.js",
  "js/manifest.js": "js/manifest.js",
  "js/vendor.js": "js/vendor.js"

what's wrong and how can solve it ,thx

mastilver commented 6 years ago

Looks like a bug... I will try to have a look tomorrow

Which version are you using? If you can provide a failing test that would be awesome

lichnow commented 6 years ago

@mastilver version is ^1.3.2,my option

new ManifestPlugin({
        filter: chunk => chunk.isInitial
      })
lichnow commented 6 years ago

solve it

manifestOpts.generate = (seed, files) => files.reduce(
            (manifest, file) => {
                let fileName = _.last(_.split(_.last(_.split(file.name,'/')),'.')) + '/' + file.name
                let filePath = _.replace(file.path, config.output.publicPath,'')
                manifest[fileName] = filePath
                return manifest;
            }, 
            seed
        )