Skip to content

Conversation

oleg-andreyev
Copy link

  • inheriting from webpack context if it's not defined
  • parseInt for maxBuffer

@localjo
Copy link
Owner

localjo commented Mar 19, 2020

Hi @oleg-andreyev thank you for your contribution! I'm sorry for the late response. I somehow missed the notification.

Could you explain to me the use case for this change, and why it's necessary to change options inside this plugin rather than passing them in from the Webpack config?

@oleg-andreyev
Copy link
Author

@localjo

  1. I'm calling "shell script" which iterates over twig templates and combines then into single file and size of this "prepared" files easily overflow default maxBuffer (1024 * 1024)
  2. cwd is actually inherited from webpack context because to ensure that exec can find this script ❓

Why it's done like so? We're migrating our project from Symfony 3.4 to 4.4 and we used use AsseticBundle (which is not deprecated) but we still use JMSTwigJsBundle.

Our entrypoint looks like this:

require('shell-loader?script=./twig-templates.sh&maxBuffer=4194304!./twig-templates.sh');

@localjo
Copy link
Owner

localjo commented Mar 19, 2020

I'm not familiar with using require syntax for setting up a Webpack plugin. Can you share some documentation for this approach?

Do you have a Webpack config file? If so, can you try passing maxBuffer from there. In order for the script to be found, you can pass the path into script in the Webpack config too, or configure a shortcut to it in package.json. Would this work in your Webpack config?

module: {
  rules: [
    {
      test: /.*\.twig$/,
      use: [{ loader: 'shell-loader', options: {
        script: './twig-templates.sh',
        maxBuffer: 4194304
      }} ]
    }
  ]
}

(Note: I'm not familiar with Twig or Symfony, so I don't know what the test should be.)

@oleg-andreyev
Copy link
Author

@localjo here is the documentation about inline loaders: https://webpack.js.org/concepts/loaders/#inline

@localjo
Copy link
Owner

localjo commented Mar 20, 2020

Thanks. I'll take a look. I'm feeling a bit under the weather right now, so it might take me awhile to get to this. Any part of your code that you can share with me will help as well. Thanks!

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