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

Support passing custom webpack config directly to generateWebpackConfig #329

Closed
G-Rath opened this issue Jul 6, 2023 · 2 comments · Fixed by #343
Closed

Support passing custom webpack config directly to generateWebpackConfig #329

G-Rath opened this issue Jul 6, 2023 · 2 comments · Fixed by #343
Assignees

Comments

@G-Rath
Copy link
Contributor

G-Rath commented Jul 6, 2023

Notice: A feature request describes a suggested improvement. If you have a debugging or troubleshooting question, please open a discussion on the Discussions Tab. Otherwise, remove this line and fill out the following sections.

Desired behavior:

'use strict';

const { generateWebpackConfig } = require('shakapacker');
const Dotenv = require('dotenv-webpack');

const customConfig = {
  plugins: [new Dotenv()],
  module: {
    rules: [
      // ...
    ]
  }
};

// See the shakacode/shakapacker README and docs directory for advice on customizing your webpackConfig.

module.exports = generateWebpackConfig(customConfig);

Actual behavior:

'use strict';

const { generateWebpackConfig, merge } = require('shakapacker');
const Dotenv = require('dotenv-webpack');

const customConfig = {
  plugins: [new Dotenv()],
  module: {
    rules: [
      // ...
    ]
  }
};

// See the shakacode/shakapacker README and docs directory for advice on customizing your webpackConfig.

module.exports = merge(generateWebpackConfig(), customConfig);

It feels like a pretty simple win given that generateWebpackConfig is just doing webpackMerge.merge anyway, and this feels like it's in the name too right?

If someone needs to do more advance stuff, they can still use merge directly themselves.

Proposed signature:

function generateWebpackConfig(customConfig?: webpack.Configuration): webpack.Configuration;

Setup environment:

  • Ruby version: 3.1.0
  • Rails version: 7.0.0
  • Shakapacker version: 7.0.2
@ahangarha
Copy link
Contributor

@justin808 You also wanted such a function to get a config object as an optional parameter. Is this proposal the same as what you had in mind?

@justin808
Copy link
Member

@G-Rath this is a great idea so long as the argument is optional and the current functionality is preserved. Or you can say that the default param is an empty object. Please submit and PR and I'll approve,.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants