question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

webpack.config.js is not updated

See original GitHub issue

When upgrading from beta2 to SNAPSHOT, you would expect #5456 to be fixed and the built artifact to be named something else than index.js. This is not the case, it is still index.js. Only if you for some reason happen to delete the autogenerated webpack.config.js, then the artifact is renamed.

As a user, I would expect the autogenerated config to be updated by a new autogenerated config, whenever it changes.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Legiothcommented, Jun 3, 2019

I’ll elaborate the practicalities of my vision from #5464 since it’s slightly vaguely.

My core idea is that the generated file could have the same contents as today, and then by default the user-owned file would look something like this:

/* A comment that describes the purpose of this structure */
const flowDefaults = require('./some/location/generated-webpack.config.js');
module.exports = flowDefaults;

The magic comes from how the user can modify flowDefaults before exporting anything. Some examples. Please note the explicit checks to verify that the original structure is as expected. This is something that we cannot force users to do, but we can show good example in any documentation that we write.

const flowDefaults = require('./some/location/generated-webpack.config.js');

// Add a custom plugin
flowDefaults.plugins.push(new MyPlugin());

// Update the rules to also transpile `.mjs` files
if (!flowDefaults.module.rules[0].test) {
  throw "Unexpected structure in generated webpack config";
}
flowDefaults.module.rules[0].test = /\.m?js$/

// Include a custom JS in the entry point in addition to generated-flow-imports.js
if (typeof flowDefaults.entry.index != "string") {
  throw "Unexpected structure in generated webpack config";
}
flowDefaults.entry.index = [flowDefaults.entry.index, "myCustomFile.js"];

module.exports = flowDefaults;
0reactions
t-gergelycommented, Oct 25, 2019

if (typeof flowDefaults.entry.index != “string”) { throw “Unexpected structure in generated webpack config”; }

I tried that based on the current webpack.config.js and it DOES throw. Then what? I hacked it to

if (typeof flowDefaults.entry.bundle != "string") {
  throw "Unexpected structure in generated webpack config";
}
flowDefaults.entry.bundle = [flowDefaults.entry.bundle, require('path').resolve(__dirname, 'myCustomFile.js')];

but that template should be fixed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack-dev-server compiles files but does not refresh or ...
In my webpack.config.js file I set the entry, output, and devServer settings as well as add a loader to look for changes in...
Read more >
Configuration - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
Webpack will not update file - MSDN - Microsoft
The problem was the scripts.js.map file still referenced the old javascript file. There was a scripts.js file that had the old code in...
Read more >
Webpack Watch Cached And Not Refreshing Bundles - LinkedIn
If you use webpack as your JavaScript bundler, you might have experienced an issue with webpack --watch not refreshing your bundles when ...
Read more >
Webpack not reloading browser after update - Developers
The reload always worked for editing js files that produce the appbundle. Things like the config and the index.hrml are always served from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found