momocow / webpack-userscript

A Webpack plugin for userscript projects. 🙈
https://cow.moe/webpack-userscript/
MIT License
202 stars 21 forks source link

webpack error when output filename ends with ".user.js" #90

Closed RudeySH closed 1 year ago

RudeySH commented 1 year ago

After updating to webpack-userscript v3.0.0+, I get the following error when I run webpack:

ERROR in Conflict: Multiple assets emit different content to the same filename exampe.user.js

This is my webpack.config.js:

const path = require('path');
const { UserscriptPlugin } = require('webpack-userscript');

module.exports = {
  entry: './example.js',
  output: {
    filename: 'example.user.js',
    path: path.resolve(__dirname, 'dist'),
  },
  plugins: [
    new UserscriptPlugin(),
  ],
};

Solution: I was able to fix the error by changing the filename to 'example.js', removing the ".user" part.

This is a breaking change compared to v2.5.8.

I doubt causing a webpack error is intended, but I'm unsure if this needs to be fixed. The main reason I'm creating this issue is so others who run into this error, find the solution here.

momocow commented 1 year ago

This is a bug.

The purpose of this behavior is to ensure the filename to be ended with .user.js, not to prevent users from explicitly specifying the file extension.

I'll fix it soon.

MisterRee commented 1 year ago

Any update on this @momocow? I've had to roll back to 2.5.8 pending the fix here.

mjpieters commented 1 year ago

Any update on this @momocow? I've had to roll back to 2.5.8 pending the fix here.

Just set your output filename to use .js instead of .user.js for now:

    output: {
      clean: true,
      path: OUTPUT,
      // Can't use [name].user.js, see momocow/webpack-userscript#90
      filename: '[name].js',
    },

See my project webpack.conf.ts.

The resulting asset is then given the .user.js extension.

inazuma-bot commented 1 year ago

:tada: This issue has been resolved in version 3.2.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: