Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question for docker/DDEV usage: --public option is deprecated? #1205

Open
mandrasch opened this issue Apr 28, 2023 · 0 comments
Open

Question for docker/DDEV usage: --public option is deprecated? #1205

mandrasch opened this issue Apr 28, 2023 · 0 comments

Comments

@mandrasch
Copy link

Hi, thanks so much for providing webpack-encore, awesome tool!

I'm a bit confused about the recent changes.

For the usage in Docker tool DDEV I use the following config and invoke encore dev-server with --public:

  "scripts": {
    "dev": "encore dev-server --public https://my-wordpress-site.ddev.site:5173",
    "watch": "encore dev --watch",
    "build": "encore production --progress",
    "build-dev": "encore dev --watch"
  },

That allowed me to achieve the following manifest.json-output with the DDEV url instead of localhost:

{
  "wp-content/themes/neve-child/dist/main.css": "https://my-wordpress-site.ddev.site:5173/wp-content/themes/neve-child/dist/main.css",
  "wp-content/themes/neve-child/dist/main.js": "https://my-wordpress-site.ddev.site:5173/wp-content/themes/neve-child/dist/main.js"
}

My webpack.config.js is the following:

.configureDevServerOptions((options) => {
   options.host = "0.0.0.0";
   options.allowedHosts = "all";
   options.port = 5173; // switch port to vite standard 
});

My .ddev/config.yaml for exposing the port:

# expose port for webpack encore dev server
web_extra_exposed_ports:
  - name: node-js
    container_port: 5173
    http_port: 5172
    https_port: 5173

I tried to move the --public setting to webpack.config.js, because I wanted to use it like that:

.configureDevServerOptions((options) => {
   options.host = "0.0.0.0";
   options.allowedHosts = "all";
   options.port = 5173; // switch port to vite standard 
   
   // new:
   options.public = `${process.env.DDEV_PRIMARY_URL}:5173`;
   
});

That gave me the error:

[webpack-cli] Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
 - options has an unknown property 'public'. These properties are valid:
   object { allowedHosts?, bonjour?, client?, compress?, devMiddleware?, headers?, historyApiFallback?, host?, hot?, http2?, https?, ipc?, liveReload?, magicHtml?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, server?, setupExitSignals?, setupMiddlewares?, static?, watchFiles?, webSocketServer? }
Task failed: Exec command 'npm run dev' in container/service 'web': exit status 2 

I saw this guide (https://github.com/webpack/webpack-dev-server/blob/master/migration-v4.md) for migration, but I was not able to use the v4 version correctly?

module.exports = {
  devServer: {
    client: {
      // Can be `string`:
      //
      // To get protocol/hostname/port from browser
      // webSocketURL: 'auto://0.0.0.0:0/ws'
      webSocketURL: {
        hostname: "0.0.0.0",
        pathname: "/ws",
        port: 8080,
      },
    },
  },
};

Always ended up with localhost:8080 in dist/manifest.json.

Two questions:

  1. Is --public a special CLI feature provided by Webpack Encore?
  2. Will it be removed in future versions?

Thanks very much in advance! I can provide a demo repository if needed of course.

(A future workaround would be to parse manifest.json via PHP and replace localhost:8080 of course). Might also be related to #1202

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

No branches or pull requests

1 participant