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

Ejecting from preact-cli isn't very obvious or simple #366

Closed
tmcw opened this issue Sep 11, 2017 · 4 comments
Closed

Ejecting from preact-cli isn't very obvious or simple #366

tmcw opened this issue Sep 11, 2017 · 4 comments
Labels

Comments

@tmcw
Copy link

tmcw commented Sep 11, 2017

Do you want to request a feature or report a bug?

I'm requesting a feature.

What is the current behavior?

Right now, when you decide to implement webpack-dev-middleware or another more low-level integration with Webpack and Preact, the route to getting there is quite difficult to navigate.

If the current behavior is a bug, please provide the steps to reproduce.

  • Try to switch away from preact-cli after starting to build an app in it
  • The async! component syntax appears to be an in-built part of preact-cli, so the only option would be to copy & paste and move to your app
  • Similarly the entry point is in preact-cli
  • And the webpack configuration is abstracted to a level that it's hard to copy & paste or adapt it into another application.

What is the expected behavior?

This route would be documented and the niceities that preact-cli provides would be in modules that were usable outside of the module

If this is a feature request, what is motivation or use case for changing the behavior?

My process was:

  • Using preact-cli, I eventually hit a level of complexity wrt proxying websockets, running a backend & frontend, and hitting problems with http-proxy, to the extent that I wanted out - to be able to run one server, one node application that both bundled and served routes.

Please mention other relevant information.

  • node version
  • npm version
  • Operating system
@developit
Copy link
Member

I would suggest this is a failing of the CLI, not of eject. Eject basically evaporates any value the CLI has over a boilerplate (updates, compartmentalization, reusability, etc).

Would the ability to invoke preact-cli programmatically and obtain a webpack configuration have helped avoid the wall you hit? Something like:

// webpack.config.js

module.exports = require('preact-cli').config({
  // options
});

@tmcw
Copy link
Author

tmcw commented Sep 11, 2017

If preact-cli exposed a server that I could compose with an existing express server at the node level, that'd be ideal.

But also exposing the Webpack config would be a huge help - wrastling webpack is easily 80% of the yak-shaving here.

@developit
Copy link
Member

Right now we recommend people do configuration via preact.config.js:

export default (config, env, helpers) => {
    env.ssr;  // Boolean indicating if this is the prerender config

    config;  // a standard webpack config!

    config.module.rules.push({
        test: /\.foo$/.
        use: 'foo-loader'
    });
};

@tmcw
Copy link
Author

tmcw commented Sep 12, 2017

Yep, I was using that, it worked fairly well.

But eventually the indirection of proxying requests, and the flakiness of the proxy approach - how I'd need to configure the backend to listen on port 5000 but accept requests intended for 8080 (and embed links to 8080), how it distorts errors, wouldn't pass-through 400 responses, and so on - meant that I wanted to remove the proxy and use webpack-dev-middleware. Additionally, running frontend & backend servers means using something like concurrently to manage the dual processes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants