From 28ebb55a95a239c25d68fb06040173f667d816c7 Mon Sep 17 00:00:00 2001 From: Greg Date: Fri, 22 Sep 2017 10:32:08 +0100 Subject: [PATCH 1/7] Update documentation with how to change config in the top level readme. Also reveal how to make use of internal functions --- README.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ docs/webpack.md | 8 ++++++++ 2 files changed, 57 insertions(+) diff --git a/README.md b/README.md index 8a4b73be4..47ce86963 100644 --- a/README.md +++ b/README.md @@ -173,6 +173,55 @@ when running `./bin/webpack-dev-server` binstub: **Note:** Don't forget to prefix `ruby` when running these binstubs on windows +### Configuration + + +Webpacker gives you a default set of configuration files for test, development and +production environments in `config/webpack/*.js`. You can configure each individual +environment in their respective files or configure them all in the base +`config/webpack/environment.js` file. + +By default, you shouldn't have to make any changes to `config/webpack/*.js` +files since it's all standard production-ready configuration. However, +if you do need to customize or add a new loader, this is where you would go. + +Here is how you can modify webpack configuration: + +```js +// config/webpack/custom.js +module.exports = { + resolve: { + alias: { + jquery: 'jquery/src/jquery', + vue: 'vue/dist/vue.js', + React: 'react', + ReactDOM: 'react-dom', + vue_resource: 'vue-resource/dist/vue-resource', + } + } +} + +// config/webpack/development.js +const merge = require('webpack-merge') +const environment = require('./environment') +const customConfig = require('./custom') + +module.exports = merge(environment.toWebpackConfig(), customConfig) +``` + +If you need access to functions within Webpacker's configuration, you can import them like this: +``` +const config = require('@rails/webpacker/package/config'); +const asset_host = require('@rails/webpacker/package/asset_host'); + +console.log(asset_host.publicPathWithHost); +``` + +**Note:** You will have to merge custom config to all env where you want that config +to be available. In above case, it will be applied to development environment. + +See [docs/Webpack](docs/webpack.md) for more details. + ## Integrations Webpacker ships with basic out-of-the-box integration for React, Angular, Vue and Elm. diff --git a/docs/webpack.md b/docs/webpack.md index b6d13be52..1d6095589 100644 --- a/docs/webpack.md +++ b/docs/webpack.md @@ -36,6 +36,14 @@ const customConfig = require('./custom') module.exports = merge(environment.toWebpackConfig(), customConfig) ``` +If you need access to functions within Webpacker's configuration, you can import them like this: +``` +const config = require('@rails/webpacker/package/config'); +const asset_host = require('@rails/webpacker/package/asset_host'); + +console.log(asset_host.publicPathWithHost); +``` + **Note:** You will have to merge custom config to all env where you want that config to be available. In above case, it will be applied to development environment. From 09793f9f9a574d3fca6777e235e932fe3c598544 Mon Sep 17 00:00:00 2001 From: Greg Date: Fri, 22 Sep 2017 10:37:27 +0100 Subject: [PATCH 2/7] Mark the blocks as JS syntax --- README.md | 2 +- docs/webpack.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 47ce86963..3823f8bbb 100644 --- a/README.md +++ b/README.md @@ -210,7 +210,7 @@ module.exports = merge(environment.toWebpackConfig(), customConfig) ``` If you need access to functions within Webpacker's configuration, you can import them like this: -``` +```js const config = require('@rails/webpacker/package/config'); const asset_host = require('@rails/webpacker/package/asset_host'); diff --git a/docs/webpack.md b/docs/webpack.md index 1d6095589..43bb46ed7 100644 --- a/docs/webpack.md +++ b/docs/webpack.md @@ -37,7 +37,7 @@ module.exports = merge(environment.toWebpackConfig(), customConfig) ``` If you need access to functions within Webpacker's configuration, you can import them like this: -``` +```js const config = require('@rails/webpacker/package/config'); const asset_host = require('@rails/webpacker/package/asset_host'); From 2d348d2d9fddb0ec75054beac448589c3427dfa0 Mon Sep 17 00:00:00 2001 From: Greg Date: Fri, 22 Sep 2017 10:40:56 +0100 Subject: [PATCH 3/7] Re-ran doctoc. Expanded see more. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3823f8bbb..6cad56b96 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ in which case you may not even need the asset pipeline. This is mostly relevant - [Installation](#installation) - [Usage](#usage) - [Development](#development) + - [Configuration](#configuration) - [Integrations](#integrations) - [React](#react) - [Angular with TypeScript](#angular-with-typescript) @@ -220,7 +221,7 @@ console.log(asset_host.publicPathWithHost); **Note:** You will have to merge custom config to all env where you want that config to be available. In above case, it will be applied to development environment. -See [docs/Webpack](docs/webpack.md) for more details. +See [docs/Webpack](docs/webpack.md) for more details on the configuration and loaders API. ## Integrations From 05dd27e70d7b9e0b07bbef2e44ab89418b2a40c5 Mon Sep 17 00:00:00 2001 From: Greg Date: Fri, 22 Sep 2017 10:47:59 +0100 Subject: [PATCH 4/7] Remove all webpack config references from main README, keep intro paragraph and link to webpack.md --- README.md | 42 ++---------------------------------------- 1 file changed, 2 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 6cad56b96..8cec4d93e 100644 --- a/README.md +++ b/README.md @@ -176,52 +176,14 @@ when running `./bin/webpack-dev-server` binstub: ### Configuration - Webpacker gives you a default set of configuration files for test, development and production environments in `config/webpack/*.js`. You can configure each individual environment in their respective files or configure them all in the base `config/webpack/environment.js` file. By default, you shouldn't have to make any changes to `config/webpack/*.js` -files since it's all standard production-ready configuration. However, -if you do need to customize or add a new loader, this is where you would go. - -Here is how you can modify webpack configuration: - -```js -// config/webpack/custom.js -module.exports = { - resolve: { - alias: { - jquery: 'jquery/src/jquery', - vue: 'vue/dist/vue.js', - React: 'react', - ReactDOM: 'react-dom', - vue_resource: 'vue-resource/dist/vue-resource', - } - } -} - -// config/webpack/development.js -const merge = require('webpack-merge') -const environment = require('./environment') -const customConfig = require('./custom') - -module.exports = merge(environment.toWebpackConfig(), customConfig) -``` - -If you need access to functions within Webpacker's configuration, you can import them like this: -```js -const config = require('@rails/webpacker/package/config'); -const asset_host = require('@rails/webpacker/package/asset_host'); - -console.log(asset_host.publicPathWithHost); -``` - -**Note:** You will have to merge custom config to all env where you want that config -to be available. In above case, it will be applied to development environment. - -See [docs/Webpack](docs/webpack.md) for more details on the configuration and loaders API. +files since it's all standard production-ready configuration. +See [docs/Webpack](docs/webpack.md) for modifying the configuration and loaders API. ## Integrations From 8b4011eb1f740a3f3867c7c1e9cab81e9effa897 Mon Sep 17 00:00:00 2001 From: Greg Date: Fri, 22 Sep 2017 11:03:43 +0100 Subject: [PATCH 5/7] Working tweaks --- README.md | 2 +- docs/webpack.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8cec4d93e..ac10fd86b 100644 --- a/README.md +++ b/README.md @@ -181,7 +181,7 @@ production environments in `config/webpack/*.js`. You can configure each individ environment in their respective files or configure them all in the base `config/webpack/environment.js` file. -By default, you shouldn't have to make any changes to `config/webpack/*.js` +By default, you don't need make any changes to `config/webpack/*.js` files since it's all standard production-ready configuration. See [docs/Webpack](docs/webpack.md) for modifying the configuration and loaders API. diff --git a/docs/webpack.md b/docs/webpack.md index 43bb46ed7..57bc369a4 100644 --- a/docs/webpack.md +++ b/docs/webpack.md @@ -8,7 +8,7 @@ production environments in `config/webpack/*.js`. You can configure each individ environment in their respective files or configure them all in the base `config/webpack/environment.js` file. -By default, you shouldn't have to make any changes to `config/webpack/*.js` +By default, you don't need to make any changes to `config/webpack/*.js` files since it's all standard production-ready configuration. However, if you do need to customize or add a new loader, this is where you would go. @@ -36,7 +36,7 @@ const customConfig = require('./custom') module.exports = merge(environment.toWebpackConfig(), customConfig) ``` -If you need access to functions within Webpacker's configuration, you can import them like this: +If you need access to configs within Webpacker's configuration, you can import them like this: ```js const config = require('@rails/webpacker/package/config'); const asset_host = require('@rails/webpacker/package/asset_host'); From fa10c4a983dffc59e1aba62c32b6e72de3287467 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Fri, 22 Sep 2017 12:04:03 +0100 Subject: [PATCH 6/7] Remove duplicate content and just link to the docs --- README.md | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ac10fd86b..368ae4df9 100644 --- a/README.md +++ b/README.md @@ -174,16 +174,9 @@ when running `./bin/webpack-dev-server` binstub: **Note:** Don't forget to prefix `ruby` when running these binstubs on windows -### Configuration +### Webpack configuration -Webpacker gives you a default set of configuration files for test, development and -production environments in `config/webpack/*.js`. You can configure each individual -environment in their respective files or configure them all in the base -`config/webpack/environment.js` file. - -By default, you don't need make any changes to `config/webpack/*.js` -files since it's all standard production-ready configuration. -See [docs/Webpack](docs/webpack.md) for modifying the configuration and loaders API. +See [docs/Webpack](docs/webpack.md) for modifying webpack configuration and loaders. ## Integrations From f493e0a6db5a6857abea1e4b55eaab5beede4957 Mon Sep 17 00:00:00 2001 From: Greg Date: Fri, 22 Sep 2017 12:51:56 +0100 Subject: [PATCH 7/7] Doctoc on Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 368ae4df9..e227aa6ae 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ in which case you may not even need the asset pipeline. This is mostly relevant - [Installation](#installation) - [Usage](#usage) - [Development](#development) - - [Configuration](#configuration) + - [Webpack configuration](#webpack-configuration) - [Integrations](#integrations) - [React](#react) - [Angular with TypeScript](#angular-with-typescript)