Skip to content

Commit

Permalink
Allow omitting options to plugin-webpack (#1047)
Browse files Browse the repository at this point in the history
It makes the developer experience slightly better, since if
you don't provide an empty object, you'll get the
`TypeError: Cannot read property 'mode' of undefined`.
  • Loading branch information
ralphtheninja committed Sep 12, 2020
1 parent a06d084 commit 3564ee5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 19 additions & 4 deletions plugins/plugin-webpack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,35 @@

Use Webpack to bundle your application for production.

### Install

```
npm install --save-dev @snowpack/plugin-webpack
```

```js
// snowpack.config.json
### Usage

Add `@snowpack/plugin-webpack` to `snowpack.config.json`:

```json
{
"plugins": [["@snowpack/plugin-webpack", { /* see "Plugin Options" below */}]]
"plugins": [["@snowpack/plugin-webpack", { /* see "Plugin Options" below */ }]]
}
```

#### Default Build Script
or to `snowpack.config.js`:

```js
module.exports = {
plugins: [["@snowpack/plugin-webpack", { /* see "Plugin Options" below */ }]]
}
```

The options object is optional.

### Default Build Script

```json
{
"scripts": {"bundle:*": "@snowpack/plugin-webpack"}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/plugin-webpack/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function getSplitChunksConfig({ numEntries }) {
};
}

module.exports = function plugin(config, args) {
module.exports = function plugin(config, args = {}) {
// Deprecated: args.mode
if (args.mode && args.mode !== "production") {
throw new Error("args.mode support has been removed.");
Expand Down

1 comment on commit 3564ee5

@vercel
Copy link

@vercel vercel bot commented on 3564ee5 Sep 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.