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

fix(config): force default output.filename #477

Merged
merged 1 commit into from
Feb 2, 2021
Merged

fix(config): force default output.filename #477

merged 1 commit into from
Feb 2, 2021

Conversation

codymikol
Copy link
Owner

This PR contains a:

  • bugfix
  • new feature
  • code refactor
  • test update
  • typo fix
  • metadata update

Motivation / Use-Case

this prevents karma-webpack from failing and also
prints out a useful error message explaining why
the webpack output.filename is ignored.

Fixes N/A

Breaking Changes

N/A

Additional Info

N/A

this prevents karma-webpack from failing and also
prints out a useful error message explaining why
the webpack output.filename is ignored.

Fixes N/A
@lk77
Copy link

lk77 commented Feb 18, 2021

Hello,

why this change ?

it was previously working fine.

karma-webpack does not currently support customized filenames via
webpack output.filename, if this is something you need consider opening an issue.
defaulting apps/[name]/assets/js/[name].bundle.js to [name].js

every output file is in the root directory now, and not in their own directories, and they are all called 'index.js', and webpack seems to add a random number to it :

/index.1721931596.js: "7897ba0a8043ef409538a45a9ecf566c56d8e54a"
/index.2115725147.js: "5a9c9117f70b83c0f6d05445cc7fefd8bb869012"
/index.2611944535.js: "afb25cd9c4d6094784849673f10664f94462f651"
/index.2882415412.js: "b39c38b5c51036253554d18f9d21f24d0bfc366f"
/index.3427415320.js: "9992e0308c5c29b2ad1cf4706421023216e86aec"
/index.1491000527.js: "4b9763bd2973df908ee137f6f041a114af910549"
/index.1674761228.js: "98899a48d8283411f35b2e3f785c0391f6e76da6"

and it generate two files commons.js and runtime.js that should not be there.

i think karma-webpack should strictly respect the webpack.config.js file.

edit :

for now this seems to work :

const webpackConfig = require('./webpack.config.test.js');

let DefaultWebpackOptionsFactory = require('karma-webpack/lib/webpack/defaults');

DefaultWebpackOptionsFactory.create = () => {
    return webpackConfig;
};

require.cache[require.resolve('karma-webpack/lib/webpack/defaults')].exports = DefaultWebpackOptionsFactory;

my webpack config is overriding the config provided by karma-webpack and i could get rid of commons.js/runtime.js and having my build files.

@@ -21,6 +21,16 @@ class KW_Controller {
}

updateWebpackOptions(newOptions) {
if (newOptions.output && newOptions.output.filename) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,

please add a flag to disable this behaviour somewhere

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

Successfully merging this pull request may close these issues.

2 participants