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

[DOCS] Examples of extending webpack configuration #1815

Open
johnboxall opened this issue Jun 4, 2024 · 1 comment
Open

[DOCS] Examples of extending webpack configuration #1815

johnboxall opened this issue Jun 4, 2024 · 1 comment

Comments

@johnboxall
Copy link
Collaborator

johnboxall commented Jun 4, 2024

The PWA Kit ships with a default Webpack configuration that can be extended:

https://github.com/SalesforceCommerceCloud/pwa-kit/blob/develop/packages/pwa-kit-dev/src/configs/webpack/config.js

Generally the pattern is to define your own webpack.config.js at your project root:

// webpack.config.js
const config = require('@salesforce/pwa-kit-react-sdk/configs/webpack/config')
const [client, ssr, rendered, clientOptional, requestProcessor]

// do whatever you want with config

module.exports = config

Extending the config can be useful for adding support for alternative webpack features like the ability to directly use CSS:

// webpack.config.js
const config = require('@salesforce/pwa-kit-react-sdk/configs/webpack/config')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')

config.forEach((c) => {
    c.module.rules.push({
        test: /\.(sa|sc|c)ss$/,
        use: [MiniCssExtractPlugin.loader, 'css-loader']
    })
    c.plugins.push(new MiniCssExtractPlugin({filename: '[name].css'}))
})

module.exports = config

It would be great if we created documentation showing how to do this for common examples.

@afraser
Copy link

afraser commented Jun 11, 2024

@johnboxall same... looks like this might help us: #1523

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