mariusbalcytis / webpack-bundle

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

Webpack error if there are no assets #59

Closed secit-pl closed 7 years ago

secit-pl commented 7 years ago

If I run the maba:webpack:dev-server on the application where are no assets defined the server start will fail with the following 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 NOT have less than 1 properties ({
        "keyword": "minProperties",
        "dataPath": ".entry",
        "schemaPath": "#/oneOf/0/minProperties",
        "params": {
          "limit": 1
        },
        "message": "should NOT have less than 1 properties",
        "schema": 1,
        "parentSchema": {
          "minProperties": 1,
          "additionalProperties": {
            "oneOf": [
              {
                "description": "The string is resolved to a module which is load
ed upon startup.",
                "minLength": 1,
                "type": "string"
              },
              {
                "description": "All modules are loaded upon startup. The last on
e is exported.",
                "$ref": "#/definitions/common.nonEmptyArrayOfUniqueStringValues"

              }
            ]
          },
          "description": "Multiple entry bundles are created. The key is the chu
nk name. The value can be a string or an array.",
          "type": "object"
        },
        "data": {}
      }).
      object { <key>: non-empty string | [non-empty string] }
      Multiple entry bundles are created. The key is the chunk name. The value c
an be a string or an array.
    * configuration.entry should be a string.
    * configuration.entry should be an array:
      [non-empty string]
    * configuration.entry should be an instance of function
      function returning an entry object or a promise..

IMHO the bundle should prevent from throwing such errors.

mariusbalcytis commented 7 years ago

Now the bundle will just exit with status code 0 for both compile and dev-server if there are no entry points.

➜  webpack2 bin/console maba:webpack:dev-server
No entry points found - not running webpack

I'd looked into making dev-server still running and watching for changes in twig files, but there are some issues with PHP process handling:

To sum it up - either process quits together with child process, either it cannot be stopped with Ctrl+C and needs manual killing.

Feel free to suggest any workarounds to handle this situation.

I'll create an issue in Process component with simplified use case.