Skip to content

Instantly share code, notes, and snippets.

@plfort
Created January 5, 2018 08:22
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save plfort/93da0ee1465f1d7f929fe5d9e6307532 to your computer and use it in GitHub Desktop.
Save plfort/93da0ee1465f1d7f929fe5d9e6307532 to your computer and use it in GitHub Desktop.
Symfony Encore trick for completion in PHPStorm (Can't analyse webpack.config.js)
...
let config = Encore.getWebpackConfig();
if(!Encore.isProduction()) {
fs.writeFile("fakewebpack.config.js", "module.exports = "+JSON.stringify(config), function(err) {
if(err) {
return console.log(err);
}
console.log("fakewebpack.config.js written");
});
}
module.exports = config;
// Then in PhpStorm webpack settings, point to the fakewebpack.config.js file
@AntoniusGolly
Copy link

fs must be included.
var fs = require("fs");

@Aerendir
Copy link

A great trick: it works!!! Many many thankyou!

@Aerendir
Copy link

Aerendir commented Apr 16, 2018

The trick works great after changing the default webpack.config.js to fakewebpackconfig.js in Preferences > Languages & Framework > JavaScript > Webpack.

Then yarn encore dev is required to generate the file with the compiled config.

@Aerendir
Copy link

There is a linked issue on symfony/webpack-encore#236

This solution has some drawbacks: read symfony/webpack-encore#236 (comment) for more information.

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