adobe / adobe/create-ccweb-add-on
Source Maps Generated in Production & Public Folder Handling Issue
- Dominant language
- TypeScript
- Stars
- 5
- Forks
- 3
- Avg merge
- 4h 14m
- Merged PRs (30d)
- 1
Description
I’ve encountered two issues while configuring Webpack for developing an Adobe Express add-on:
1. **Source Maps Generated in Production:**
Despite setting `mode: "production"`, Webpack continues to generate `.js.map` files. This unnecessarily increases bundle size and may expose source code.
2. **Manual Public Folder Specification:**
When using `CopyWebpackPlugin`, I had to manually specify the `public` folder. Ideally, Webpack should handle this dynamically and not throw an error if the folder is missing.
**Why the Public Folder Matters for Adobe Express Add-ons:**
Adobe Express add-ons often require storing static assets such as JSON configuration files, icons, and other resources. The `public` folder serves as a place for these assets, ensuring they are included in the final build without being processed by Webpack. Having a reliable and error-free way to include these files is essential for seamless integration with Adobe Express.
**Steps to Reproduce:**
1. Configure Webpack with `mode: "production"`.
2. Run `webpack --mode production`.
3. Observe that `.js.map` files are still generated in the output directory.
4. There is no Public folder in src folder
**Expected Behavior:**
- `.js.map` files should not be generated in production unless explicitly enabled.
- `CopyWebpackPlugin` Public folder should be added by default into src folder and webpack should copy files and folders inside public into dist
**Suggested Solutions:**
- Update `devtool` to:
```js
devtool: isEnvProduction ? false : "source-map"
```
This ensures source maps are only generated in development mode.
- Modify `CopyWebpackPlugin` to:
```js
new CopyWebpackPlugin({
patterns: [
{ from: path.resolve(__dirname, "src/public"), to: "", noErrorOnMissing: true },
],
})
```
This prevents errors when the `public` folder is missing.
Would appreciate any insights on whether this is intended behavior or if improvements can be made. Thank you! 🚀
Contributor guide
Research direction
Start by running `webpack --mode production` and inspect the Webpack configuration for its `devtool` setting and `CopyWebpackPlugin` pattern. Check the output directory for `.js.map` files and copied `src/public` contents, including behavior when that folder is missing. Done means production omits source maps unless enabled and public assets are copied to `dist` without a missing-folder error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, webpack
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100