user14431718
user14431718

Reputation:

How to aliasing Preact with Webpack?

Preact guide says

To alias any package in webpack, you need to add the resolve.alias section to your config. Depending on the configuration you're using, this section may already be present, but missing the aliases for Preact.

But using any of the official templates (default, typescript, material web components, etc...) doesn't generate any webpack.config.js file and preact has no eject command like react to access the full project configuration.

Upvotes: 1

Views: 1583

Answers (1)

rschristian
rschristian

Reputation: 2966

So, few things:

Firstly, Preact and Preact-CLI are two separate items.

You're quoting the section from our docs labeled "Integrating into an existing pipeline". This means adding Preact to an existing React application of yours, but, if you're using one of our templates, then this is a new project, not an existing one.

preact has no eject command like react to access the full project configuration.

There is no way to "eject" React. What you're referring to is the build tool called "Create React App".

We do allow for full configuration of the Webpack config with a preact.config.js. With this, you can edit any parts of the config that you'd like: change plugin options, add loaders, remove plugins, etc., without owning the configuration yourself. You can just comment out your changes in your config and you're back to the default config.

We believe CRA's "eject" is a poor API and therefore don't match it.

Upvotes: 1

Related Questions