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

[FEATURE] Extend webpack #1523

Closed
kylegoines opened this issue Nov 3, 2023 · 3 comments
Closed

[FEATURE] Extend webpack #1523

kylegoines opened this issue Nov 3, 2023 · 3 comments

Comments

@kylegoines
Copy link

Is your feature request related to a problem? Please describe.
You should be able to extend the webpack.config.js instance of the pwa-kit-dev using webpack-merge If i currently set up a webpack.config.js, all required functionality of pwa-kit fails as it has been overwritten.

@kylegoines
Copy link
Author

kylegoines commented Nov 3, 2023

the docs describe

"The Retail React App imports readymade Webpack configurations for the client side and server side form the PWA Kit React SDK. In most cases, you don’t need to change these configurations, but if you do, you can extend the Webpack configuration in webpack.config.js."

on https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/retail-react-app.html#webpack

@vmarta
Copy link
Contributor

vmarta commented Nov 6, 2023

Hi @kylegoines , what does your project's webpack.config.js look like? Does it import the original config file from pwa-kit-dev and then re-export it?

One way to extend it is something like:

const config = require('@salesforce/pwa-kit-dev/configs/webpack/config')

// Add your customizations here
const clientConfig = config.find((cnf) => cnf.name === 'client')

module.exports = config

@kylegoines
Copy link
Author

kylegoines commented Nov 6, 2023

This is amazing! thank you so much for your help - this should be added to the docs its very helpful!!!

for my exact usecase i needed to require

const config = require('pwa-kit-dev/configs/webpack/config')

but i was able to extend my alias like this now

config.forEach((cnf)=>{
    cnf.resolve.alias = {...cnf.resolve.alias, 
        '@components': path.resolve(__dirname, 'app/components/')
    }
})

thank you again :)


a little more context for people finding this issue later: pwa-kit doesn't expose the webpack.config out of the box. @vmarta 's solution allows you to expose a webpack.config.js at your project root, just be careful what you overwrite/extend.

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

2 participants