mariusbalcytis / webpack-bundle

Bundle to Integrate Webpack into Symfony
MIT License
122 stars 36 forks source link

An error in "enabled_bundles" configuration triggers a Webpack error #70

Closed alexislefebvre closed 7 years ago

alexislefebvre commented 7 years ago

I misconfigured this Bundle by using this configuration:

maba_webpack:
    enabled_bundles:
        - "FooBundle"

FooBundle exists but didn't contain any call to webpack_asset().

I had an error when I compiled through webpack:

$ app/console --env=prod maba:webpack:compile
[2017-06-15 14:55:04] app.ERROR: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.  - configuration.entry should be one of these:    object { <key>: non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function    The entry point(s) of the compilation.    Details:     * configuration.entry should be an object.     * configuration.entry should be a string.     * configuration.entry should not be empty.     * configuration.entry should be an instance of function       function returning an entry object or a promise..
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.entry should be one of these:
   object { <key>: non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function
   The entry point(s) of the compilation.
   Details:
    * configuration.entry should be an object.
    * configuration.entry should be a string.
    * configuration.entry should not be empty.
    * configuration.entry should be an instance of function
      function returning an entry object or a promise..

  [Symfony\Component\Process\Exception\ProcessFailedException]                                                                 
  The command "'node_modules/.bin/webpack' '--config' '/dev/shm/enpc_cache/prod/webpack.config.js'" failed.                    
  Exit Code: 1(General error)                                                                                                  
  Working directory: /home/alexis/Works/enpc/center/app/..                                                                     
  Output:                                                                                                                      
  ================                                                                                                             
  Error Output:                                                                                                                
  ================                                                                                                             
  Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.  
   - configuration.entry should be one of these:                                                                               
     object { <key>: non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function                
     The entry point(s) of the compilation.                                                                                    
     Details:                                                                                                                  
      * configuration.entry should be an object.                                                                               
      * configuration.entry should be a string.                                                                                
      * configuration.entry should not be empty.                                                                               
      * configuration.entry should be an instance of function                                                                  
        function returning an entry object or a promise..                                                                      

I think the root of the problem is in the app/cache/prod/webpack.config.js file:

module.exports = require("\/…\/app\/config\/webpack.config.js")({"entry":[],"groups":[],"alias":{"@ENPCPortailBundle":"\/…\/src\/ENPC\/PortailBundle","@npm":"\/…\/node_modules","@composer":"\/…\/vendor","@root":"\/…"},"manifest_path":"\/…\/cache\/prod\/webpack_manifest.json","environment":"prod","parameters":[]});

Note the empty "entry":[] node.

I think that there should be a check when Twig files are parsed and that no entry point is found, in order to display a warning instead of creating a webpack.config.js file that will break Webpack.

mariusbalcytis commented 7 years ago

Duplicate of #59, was fixed in 989bece. Sorry, missed tagging the repository, so change was only in master branch. Tagged latest release with tests fix, so it should be ok once updated.