Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
RudeySH opened this issue Mar 14, 2023 · 4 comments
Closed

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

RudeySH opened this issue Mar 14, 2023 · 4 comments
Labels
bug Something isn't working released

Comments

@RudeySH
Copy link
Contributor

RudeySH commented Mar 14, 2023

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 momocow added the bug Something isn't working label Mar 15, 2023
@momocow
Copy link
Owner

momocow commented Mar 15, 2023

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
Copy link

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

@mjpieters
Copy link
Contributor

mjpieters commented Apr 1, 2023

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
Copy link
Collaborator

🎉 This issue has been resolved in version 3.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

No branches or pull requests

5 participants