Skip to content

Commit

Permalink
📝 update docs for new webpack modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
SimulatedGREG committed Oct 15, 2017
1 parent 31afb44 commit 70bfa7d
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 6 deletions.
4 changes: 3 additions & 1 deletion docs/en/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ Here are some of the awesome features you'll find using `electron-webpack`...
* Use of [`webpack-dev-server`](https://github.com/webpack/webpack-dev-server) for development
* HMR for both `renderer` and `main` processes
* Use of [`babel-preset-env`](https://github.com/babel/babel-preset-env) that is automatically configured based on your `electron` version
* Ability to add custom `webpack` loaders, plugins, etc.
* [Add-ons](./add-ons.md) to support items like [TypeScript](http://www.typescriptlang.org/), [Less](http://lesscss.org/), [EJS](http://www.embeddedjs.com/), etc.

## Quick Start
Get started fast with [electron-webpack-quick-start](https://github.com/electron-userland/electron-webpack-quick-start).
```bash
# copy template using curl
# create a directory of your choice, and copy template using curl
mkdir my-project && cd my-project
curl -fsSL https://github.com/electron-userland/electron-webpack-quick-start/archive/master.tar.gz | tar -xz --strip-components 1

# or copy template using git clone
Expand Down
1 change: 1 addition & 0 deletions docs/en/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [Dll Bundle Splitting](dll-bundle-splitting.md)
* [Environment Variables](environment-variables.md)
* [Extending as a Library](extending-as-a-library.md)
* [Modifying Webpack Configurations](modifying-webpack-configurations.md)
* [Using Static Assets](using-static-assets.md)
* [Project Structure](project-structure.md)
* [Building](building.md)
Expand Down
23 changes: 21 additions & 2 deletions docs/en/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ Configurations can be applied in `package.json` at `electronWebpack` or in a sep

"main": {
"extraEntries": ["@/preload.js"],
"sourceDirectory": "src/main"
"sourceDirectory": "src/main",
"webpackConfig": "custom.webpack.additions.js"
},

"renderer": {
"dll": ["fooModule"],
"sourceDirectory": "src/renderer"
"sourceDirectory": "src/renderer",
"webpackConfig": "custom.webpack.additions.js",
"WebpackDllConfig": "custom.webpackDll.additions.js"
}
}
```
Expand Down Expand Up @@ -88,3 +91,19 @@ Since `webpack` is set to target the `electron` environment, all modules are tre
"whiteListedModules": ["foo-ui-library"]
}
```

### Modified Webpack Configurations
See [Modifying Webpack Configurations](modifying-webpack-configurations.md) for more information.

```json
"electronWebpack": {
"main": {
"webpackConfig": "custom.additions.webpack.js"
},

"renderer": {
"webpackConfig": "custom.additions.webpack.js",
"webpackDllConfig": "custom.additions.webpack.js"
}
}
```
1 change: 0 additions & 1 deletion docs/en/extending-as-a-library.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ One of the great benefits of using `electron-webpack` is that the entirity of `w
* `electron-webpack/webpack.main.config.js` (`main` process)
* `electron-webpack/webpack.renderer.config.js` (`renderer` process)
* `electron-webpack/webpack.renderer.dll.config.js` (Dll bundle spliting)
* `electron-webpack/webpack.app.config.js` (combination of all configurations above)

If you are wanting to look at these configurations internally, you can easily do the following to print them into your console. Notice that each configuration returns a `Promise`.

Expand Down
46 changes: 46 additions & 0 deletions docs/en/modifying-webpack-configurations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Modifying Webpack Configurations

Another great benefit of using `electron-wepback` is that you are never restricted to an abstracted API. Of course there isn't a configuration that fits everybody's need, and `electron-webpack` is aware of that.

Thanks to the power of `webpack-merge`, it is possible to apply your own webpack loaders, plugins, etc. You can easily define your own webpack additions, and `electron-webpack` will internally merge those additions with its predefined configuration. The benefit of using this method, as opposed to [Extending as a Library](extending-as-a-library.md), is that you don't lose access to using the `electron-webpack` CLI, which is very beneficial for development.

Custom modifications can be made for the `renderer`, `renderer-dll`, and `main` processes. Since `webpack-merge` is used, you can use the full potential of `webpack`'s configuration API. See [Configuration](configuration.md) for more information.

### Use Case
Let's say our project needs to be able to import `*.txt` files in the `renderer` process. We can use `raw-loader` to get that done.

##### Install `raw-loader`
```bash
yarn add raw-loader --dev
```

##### Define `raw-loader`
Notice that the full `webpack` API is usable and not blocked. You could also defined other loaders and plugins here. Please know that making major modifications may break expected behavior.
```js
/* webpack.renderer.additions.js */

module.exports = {
module: {
rules: [
{
test: /\.txt$/,
use: 'raw-loader'
}
]
}
}
```

##### Define custom configurations
See [Configuration](configuration.md) for more information.
```json
{
"electronWebpack": {
"renderer": {
"webpackConfig": "webpack.renderer.additions.js"
}
}
}
```

Now when running `electron-webpack`'s CLI, your custom additions will be loaded in and you can use them as expected. If you need even more control over the configuration, then maybe [Extending as a Library](extending-as-a-library.md) can better suit your needs.
6 changes: 4 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ Here are some of the awesome features you'll find using `electron-webpack`...
* Use of [`webpack-dev-server`](https://github.com/webpack/webpack-dev-server) for development
* HMR for both `renderer` and `main` processes
* Use of [`babel-preset-env`](https://github.com/babel/babel-preset-env) that is automatically configured based on your `electron` version
* [Add-ons](./add-ons.md) to support items like [TypeScript](http://www.typescriptlang.org/), [Less](http://lesscss.org/), [EJS](http://www.embeddedjs.com/), etc.
* Ability to add custom `webpack` loaders, plugins, etc.
* [Add-ons](https://webpack.electron.build/add-ons) to support items like [TypeScript](http://www.typescriptlang.org/), [Less](http://lesscss.org/), [EJS](http://www.embeddedjs.com/), etc.

## Quick Start
Get started fast with [electron-webpack-quick-start](https://github.com/electron-userland/electron-webpack-quick-start).
```bash
# copy template using curl
# create a directory of your choice, and copy template using curl
mkdir my-project && cd my-project
curl -fsSL https://github.com/electron-userland/electron-webpack-quick-start/archive/master.tar.gz | tar -xz --strip-components 1

# or copy template using git clone
Expand Down

0 comments on commit 70bfa7d

Please sign in to comment.