webpacker-for-component 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.js +14 -0
  3. data/.gitignore +6 -0
  4. data/.rubocop.yml +124 -0
  5. data/.travis.yml +22 -0
  6. data/Gemfile +13 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.md +325 -0
  9. data/Rakefile +12 -0
  10. data/docs/assets.md +106 -0
  11. data/docs/css.md +82 -0
  12. data/docs/deployment.md +39 -0
  13. data/docs/env.md +65 -0
  14. data/docs/es6.md +53 -0
  15. data/docs/folder-structure.md +66 -0
  16. data/docs/misc.md +23 -0
  17. data/docs/props.md +105 -0
  18. data/docs/testing.md +45 -0
  19. data/docs/troubleshooting.md +65 -0
  20. data/docs/typescript.md +116 -0
  21. data/docs/webpack-dev-server.md +32 -0
  22. data/docs/webpack.md +156 -0
  23. data/docs/yarn.md +12 -0
  24. data/lib/install/angular.rb +15 -0
  25. data/lib/install/bin/webpack-dev-server.tt +68 -0
  26. data/lib/install/bin/webpack.tt +30 -0
  27. data/lib/install/config/.babelrc +18 -0
  28. data/lib/install/config/.postcssrc.yml +3 -0
  29. data/lib/install/config/webpack/development.js +3 -0
  30. data/lib/install/config/webpack/environment.js +3 -0
  31. data/lib/install/config/webpack/production.js +3 -0
  32. data/lib/install/config/webpack/test.js +3 -0
  33. data/lib/install/config/webpacker.yml +56 -0
  34. data/lib/install/elm.rb +24 -0
  35. data/lib/install/examples/angular/hello_angular.js +7 -0
  36. data/lib/install/examples/angular/hello_angular/app/app.component.ts +9 -0
  37. data/lib/install/examples/angular/hello_angular/app/app.module.ts +16 -0
  38. data/lib/install/examples/angular/hello_angular/index.ts +8 -0
  39. data/lib/install/examples/angular/hello_angular/polyfills.ts +73 -0
  40. data/lib/install/examples/angular/tsconfig.json +19 -0
  41. data/lib/install/examples/elm/Main.elm +54 -0
  42. data/lib/install/examples/elm/hello_elm.js +11 -0
  43. data/lib/install/examples/react/.babelrc +6 -0
  44. data/lib/install/examples/react/hello_react.jsx +26 -0
  45. data/lib/install/examples/vue/app.vue +22 -0
  46. data/lib/install/examples/vue/hello_vue.js +44 -0
  47. data/lib/install/javascript/packs/application.js +10 -0
  48. data/lib/install/react.rb +28 -0
  49. data/lib/install/template.rb +35 -0
  50. data/lib/install/vue.rb +12 -0
  51. data/lib/tasks/installers.rake +22 -0
  52. data/lib/tasks/webpacker-for-component/check_binstubs.rake +12 -0
  53. data/lib/tasks/webpacker-for-component/check_node.rake +25 -0
  54. data/lib/tasks/webpacker-for-component/check_yarn.rake +24 -0
  55. data/lib/tasks/webpacker-for-component/clobber.rake +16 -0
  56. data/lib/tasks/webpacker-for-component/compile.rake +34 -0
  57. data/lib/tasks/webpacker-for-component/install.rake +13 -0
  58. data/lib/tasks/webpacker-for-component/verify_install.rake +16 -0
  59. data/lib/tasks/webpacker-for-component/yarn_install.rake +6 -0
  60. data/lib/tasks/webpacker.rake +19 -0
  61. data/lib/webpacker-for-component.rb +28 -0
  62. data/lib/webpacker-for-component/commands.rb +23 -0
  63. data/lib/webpacker-for-component/compiler.rb +78 -0
  64. data/lib/webpacker-for-component/configuration.rb +88 -0
  65. data/lib/webpacker-for-component/dev_server.rb +51 -0
  66. data/lib/webpacker-for-component/dev_server_proxy.rb +25 -0
  67. data/lib/webpacker-for-component/helper.rb +65 -0
  68. data/lib/webpacker-for-component/instance.rb +44 -0
  69. data/lib/webpacker-for-component/manifest.rb +79 -0
  70. data/lib/webpacker-for-component/railtie.rb +41 -0
  71. data/lib/webpacker-for-component/version.rb +4 -0
  72. data/package.json +62 -0
  73. data/package/asset_host.js +21 -0
  74. data/package/config.js +8 -0
  75. data/package/environment.js +95 -0
  76. data/package/environments/development.js +46 -0
  77. data/package/environments/production.js +34 -0
  78. data/package/environments/test.js +3 -0
  79. data/package/index.js +16 -0
  80. data/package/loaders/babel.js +11 -0
  81. data/package/loaders/coffee.js +4 -0
  82. data/package/loaders/elm.js +19 -0
  83. data/package/loaders/erb.js +9 -0
  84. data/package/loaders/file.js +15 -0
  85. data/package/loaders/style.js +31 -0
  86. data/package/loaders/typescript.js +4 -0
  87. data/package/loaders/vue.js +12 -0
  88. data/test/command_test.rb +27 -0
  89. data/test/compiler_test.rb +20 -0
  90. data/test/configuration_test.rb +56 -0
  91. data/test/dev_server_test.rb +24 -0
  92. data/test/helper_test.rb +39 -0
  93. data/test/manifest_test.rb +20 -0
  94. data/test/test_app/config/secrets.yml +5 -0
  95. data/test/webpacker_test_helper.rb +40 -0
  96. data/webpacker-for-component.gemspec +23 -0
  97. data/yarn.lock +5162 -0
  98. metadata +111 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b6b0cb036af66469919730cd4769282678d7f72
4
- data.tar.gz: 16cf6c1acc92b8e570cc5867aa27e6643dd2c7da
3
+ metadata.gz: 58621a72e8320c778a101cc6570c4eeb78acc725
4
+ data.tar.gz: 7d8f23cb64174abad6bec861c75c0b6e2c3d70b8
5
5
  SHA512:
6
- metadata.gz: 96f9e30c4bba49fe8150ad28b185659115f5c7c6ebfb2edc85fa231857e64bb4bd24dffe7bb077a7c7945cb2f174f2de2f2927b9de72eea0c84411fcd8ff20fa
7
- data.tar.gz: d2c0e2e587d48b3b3855ed926897b373164d5d67fa237e642a9f20180d17b27a2cfe65e7a05c235670e9f94cbe6bc05e3d36ef7d0381c3f92a50a250ec56f575
6
+ metadata.gz: 4a6d1e19154c753d3e76b6949b8ae3eba80406126c55c330d884bba096d57c6470b4ada7c22b7200402e89f6f5e56809bfa88c8eda648e2bc3026a394cbf33f1
7
+ data.tar.gz: 0f6808de0db20c99892c59bc3c5e77bd248a3e90ba296e2f51429f61f7ead0501ab8159d8a4a470275f8fea206b73ba42a3c1233158849f4b0979f1ae9797653
data/.eslintrc.js ADDED
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ 'extends': 'airbnb',
3
+ 'rules': {
4
+ 'comma-dangle': ['error', 'never'],
5
+ 'import/no-unresolved': 'off',
6
+ 'import/no-extraneous-dependencies': 'off',
7
+ 'import/extensions': 'off',
8
+ semi: ['error', 'never'],
9
+ },
10
+ 'env': {
11
+ 'browser': true,
12
+ 'node': true,
13
+ },
14
+ };
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ /.bundle
2
+ /pkg
3
+ /test/test_app/log
4
+ node_modules
5
+ .byebug_history
6
+ /test/test_app/tmp
data/.rubocop.yml ADDED
@@ -0,0 +1,124 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.2
3
+ # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
4
+ # to ignore them, so only the ones explicitly set in this file are enabled.
5
+ DisabledByDefault: true
6
+ Exclude:
7
+ - 'lib/install/templates/**'
8
+ - 'vendor/**/*'
9
+ - 'node_modules/**/*'
10
+
11
+ # Prefer &&/|| over and/or.
12
+ Style/AndOr:
13
+ Enabled: true
14
+
15
+ # Do not use braces for hash literals when they are the last argument of a
16
+ # method call.
17
+ Style/BracesAroundHashParameters:
18
+ Enabled: true
19
+
20
+ # Align `when` with `case`.
21
+ Layout/CaseIndentation:
22
+ Enabled: true
23
+
24
+ # Align comments with method definitions.
25
+ Layout/CommentIndentation:
26
+ Enabled: true
27
+
28
+ # No extra empty lines.
29
+ Layout/EmptyLines:
30
+ Enabled: true
31
+
32
+ # In a regular class definition, no empty lines around the body.
33
+ Layout/EmptyLinesAroundClassBody:
34
+ Enabled: true
35
+
36
+ # In a regular method definition, no empty lines around the body.
37
+ Layout/EmptyLinesAroundMethodBody:
38
+ Enabled: true
39
+
40
+ # In a regular module definition, no empty lines around the body.
41
+ Layout/EmptyLinesAroundModuleBody:
42
+ Enabled: true
43
+
44
+ # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
45
+ Style/HashSyntax:
46
+ Enabled: true
47
+
48
+ # Method definitions after `private` or `protected` isolated calls need one
49
+ # extra level of indentation.
50
+ Layout/IndentationConsistency:
51
+ Enabled: true
52
+ EnforcedStyle: rails
53
+
54
+ # Two spaces, no tabs (for indentation).
55
+ Layout/IndentationWidth:
56
+ Enabled: true
57
+
58
+ Layout/SpaceAfterColon:
59
+ Enabled: true
60
+
61
+ Layout/SpaceAfterComma:
62
+ Enabled: true
63
+
64
+ Layout/SpaceAroundEqualsInParameterDefault:
65
+ Enabled: true
66
+
67
+ Layout/SpaceAroundKeyword:
68
+ Enabled: true
69
+
70
+ Layout/SpaceAroundOperators:
71
+ Enabled: true
72
+
73
+ Layout/SpaceBeforeFirstArg:
74
+ Enabled: true
75
+
76
+ # Defining a method with parameters needs parentheses.
77
+ Style/MethodDefParentheses:
78
+ Enabled: true
79
+
80
+ # Use `foo {}` not `foo{}`.
81
+ Layout/SpaceBeforeBlockBraces:
82
+ Enabled: true
83
+
84
+ # Use `foo { bar }` not `foo {bar}`.
85
+ Layout/SpaceInsideBlockBraces:
86
+ Enabled: true
87
+
88
+ # Use `{ a: 1 }` not `{a:1}`.
89
+ Layout/SpaceInsideHashLiteralBraces:
90
+ Enabled: true
91
+
92
+ Layout/SpaceInsideParens:
93
+ Enabled: true
94
+
95
+ # Check quotes usage according to lint rule below.
96
+ Style/StringLiterals:
97
+ Enabled: true
98
+ EnforcedStyle: double_quotes
99
+
100
+ # Detect hard tabs, no hard tabs.
101
+ Layout/Tab:
102
+ Enabled: true
103
+
104
+ # Blank lines should not have any spaces.
105
+ Layout/TrailingBlankLines:
106
+ Enabled: true
107
+
108
+ # No trailing whitespace.
109
+ Layout/TrailingWhitespace:
110
+ Enabled: true
111
+
112
+ # Use quotes for string literals when they are enough.
113
+ Style/UnneededPercentQ:
114
+ Enabled: true
115
+
116
+ # Align `end` with the matching keyword or starting expression except for
117
+ # assignments, where it should be aligned with the LHS.
118
+ Lint/EndAlignment:
119
+ Enabled: true
120
+ EnforcedStyleAlignWith: variable
121
+
122
+ # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
123
+ Lint/RequireParentheses:
124
+ Enabled: true
data/.travis.yml ADDED
@@ -0,0 +1,22 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.6
5
+ - 2.3.3
6
+ - 2.4.1
7
+ cache:
8
+ bundler: true
9
+ directories:
10
+ - node_modules
11
+ yarn: true
12
+
13
+ install:
14
+ - bundle install
15
+ - nvm install node
16
+ - node -v
17
+ - npm i -g yarn
18
+ - yarn
19
+ script:
20
+ - yarn lint
21
+ - bundle exec rubocop
22
+ - bundle exec rake test
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "rails"
6
+ gem "rake", ">= 11.1"
7
+ gem "rubocop", ">= 0.49", require: false
8
+ gem "rack-proxy", require: false
9
+
10
+ group :test do
11
+ gem "minitest", "~> 5.0"
12
+ gem "byebug"
13
+ end
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2016 David Heinemeier Hansson, Basecamp
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,325 @@
1
+ # Webpacker-for-component
2
+
3
+
4
+ Webpacker-for-component makes it easy to use the JavaScript pre-processor and bundler
5
+ [Webpack 3.x.x+](https://webpack.js.org/) adapted to rails engines.
6
+ It manages components JavaScript in Rails. It coexists with the asset pipeline,
7
+ as the primary purpose for Webpack is app-like JavaScript, not images, CSS, or
8
+ even JavaScript Sprinkles (that all continues to live in app/assets).
9
+
10
+ However, it is possible to use Webpacker for CSS, images and fonts assets as well,
11
+ in which case you may not even need the asset pipeline. This is mostly relevant when exclusively using component-based JavaScript frameworks.
12
+
13
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
14
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
15
+ ## Table of Contents
16
+
17
+ - [Prerequisites](#prerequisites)
18
+ - [Features](#features)
19
+ - [Installation](#installation)
20
+ - [Usage](#usage)
21
+ - [Development](#development)
22
+ - [Integrations](#integrations)
23
+ - [React](#react)
24
+ - [Angular with TypeScript](#angular-with-typescript)
25
+ - [Vue](#vue)
26
+ - [Elm](#elm)
27
+ - [Paths](#paths)
28
+ - [Resolved](#resolved)
29
+ - [Watched](#watched)
30
+ - [Deployment](#deployment)
31
+ - [Docs](#docs)
32
+ - [License](#license)
33
+
34
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
35
+
36
+ ## Credits
37
+ This version of webpacker is highly adapted from the regular webpacker version povided by David Heinemeier Hansson and
38
+ Gaurav Tiwari. I would like to use webpacker inside an engine for a specific project and could not find a way to do it
39
+ without modifying the code base of webpacker.
40
+
41
+ ## Prerequisites
42
+
43
+ * Ruby 2.2+
44
+ * Rails 4.2+
45
+ * Node.js 6.0.0+
46
+ * Yarn 0.25.2+
47
+
48
+
49
+ ## Features
50
+
51
+ * [Webpack .x.x](https://webpack.js.org/)
52
+ * ES6 with [babel](https://babeljs.io/)
53
+ * Automatic code splitting using multiple entry points
54
+ * Stylesheets - SASS and CSS
55
+ * Images and fonts
56
+ * PostCSS - Auto-Prefixer
57
+ * Asset compression, source-maps, and minification
58
+ * CDN support
59
+ * React, Angular, Elm and Vue support out-of-the-box
60
+ * Rails view helpers
61
+ * Extensible and configurable
62
+
63
+
64
+ ## Installation
65
+
66
+ # Gemfile
67
+ gem 'webpacker-for-component', '~> 1.1.0'
68
+
69
+ and run following within your component to install webpacker:
70
+
71
+ ```bash
72
+ bundle
73
+ bundle exec rails app:webpacker:install
74
+
75
+ # OR (on rails version < 5.0)
76
+ bundle exec rake webpacker:install
77
+ ```
78
+
79
+ ### Usage
80
+
81
+ Once installed you can start writing modern ES6-flavored JavaScript app today:
82
+
83
+ ```yml
84
+ app/javascript:
85
+ ├── packs:
86
+ │ # only webpack entry files here
87
+ │ └── application.js
88
+ └── src:
89
+ │ └── application.css
90
+ └── images:
91
+ └── logo.svg
92
+ ```
93
+
94
+ You can then link the javascript pack in Rails view using `javascript_pack_tag` helper.
95
+ If you have styles imported in your pack file, you can link using `stylesheet_pack_tag`:
96
+
97
+ ```erb
98
+ <%= javascript_pack_tag 'application' %>
99
+ <%= stylesheet_pack_tag 'application' %>
100
+ ```
101
+
102
+ If you want to link a static asset for `<link rel="prefetch">` or `<img />` tag, you
103
+ can use `asset_pack_path` helper:
104
+
105
+ ```erb
106
+ <link rel="prefetch" href="<%= asset_pack_path 'application.css' %>" />
107
+ <img src="<%= asset_pack_path 'images/logo.svg' %>" />
108
+ ```
109
+
110
+ **Note:** In order for your styles or static assets files to be available in your view,
111
+ you would need to link them in your "pack" or entry file.
112
+
113
+ ### Development
114
+
115
+ Webpacker ships with two binstubs: `./bin/webpack` and `./bin/webpack-dev-server`.
116
+ Both are thin wrappers around the standard `webpack.js` and `webpack-dev-server.js`
117
+ executable to ensure that the right configuration file and environment variables
118
+ are loaded depending on your environment.
119
+
120
+ In development, Webpacker compiles on demand rather than upfront by default. This
121
+ happens when you refer to any of the pack assets using the Webpacker helper methods.
122
+ That means you don't have to run any separate process. Compilation errors are logged
123
+ to the standard Rails log.
124
+
125
+ If you want to use live code reloading, or you have enough JavaScript that on-demand compilation is too slow, you'll need to run `./bin/webpack-dev-server` or `ruby ./bin/webpack-dev-server` if on windows,
126
+ in a separate terminal from `bundle exec rails s`. This process will watch for changes
127
+ in the `app/javascript/packs/*.js` files and automatically reload the browser to match.
128
+
129
+ ```bash
130
+ # webpack dev server
131
+ ./bin/webpack-dev-server
132
+
133
+ # watcher
134
+ ./bin/webpack --colors --progress
135
+
136
+ # standalone build
137
+ ./bin/webpack
138
+ ```
139
+
140
+ Once you start this development server, Webpacker will automatically start proxying all
141
+ webpack asset requests to this server. When you stop the server, it'll revert to
142
+ on-demand compilation again.
143
+
144
+ You can also pass CLI options supported by [webpack-dev-server](https://webpack.js.org/configuration/dev-server/). Please note that inline options will always take
145
+ precedence over the ones already set in the configuration file.
146
+
147
+ ```bash
148
+ ./bin/webpack-dev-server --host example.com --inline true --hot false
149
+ ```
150
+
151
+ By default, webpack dev server listens on `localhost` in development for security
152
+ but if you want your app to be available over local LAN IP or VM instance like vagrant
153
+ you can pass an additional config option `--listen-host`
154
+ when running `./bin/webpack-dev-server` binstub:
155
+
156
+ ```bash
157
+ ./bin/webpack-dev-server --listen-host 0.0.0.0
158
+ ```
159
+
160
+ **Note:** Don't forget to prefix `ruby` when running these binstubs on windows
161
+
162
+ ## Integrations
163
+
164
+ Webpacker ships with basic out-of-the-box integration for React, Angular, Vue and Elm.
165
+ You can see a list of available commands/tasks by running `bundle exec rails webpacker`:
166
+
167
+ ### React
168
+
169
+ To use Webpacker with [React](https://facebook.github.io/react/), create a
170
+ new Rails 5.1+ app using `--webpack=react` option:
171
+
172
+ ```bash
173
+ # Rails 5.1+
174
+ rails new myapp --webpack=react
175
+ ```
176
+
177
+ (or run `bundle exec rails webpacker:install:react` in a existing Rails app already
178
+ setup with webpacker).
179
+
180
+ The installer will add all relevant dependencies using yarn, any changes
181
+ to the configuration files and an example React component to your
182
+ project in `app/javascript/packs` so that you can experiment with React right away.
183
+
184
+
185
+ ### Angular with TypeScript
186
+
187
+ To use Webpacker with [Angular](https://angularjs.org/), create a
188
+ new Rails 5.1+ app using `--webpack=angular` option:
189
+
190
+ ```bash
191
+ # Rails 5.1+
192
+ rails new myapp --webpack=angular
193
+ ```
194
+
195
+ (or run `bundle exec rails webpacker:install:angular` on a Rails app already
196
+ setup with webpacker).
197
+
198
+ The installer will add TypeScript and Angular core libraries using yarn plus
199
+ any changes to the configuration files. An example component is written in
200
+ TypeScript will also be added to your project in `app/javascript` so that
201
+ you can experiment with Angular right away.
202
+
203
+
204
+ ### Vue
205
+
206
+ To use Webpacker with [Vue](https://vuejs.org/), create a
207
+ new Rails 5.1+ app using `--webpack=vue` option:
208
+
209
+ ```bash
210
+ # Rails 5.1+
211
+ rails new myapp --webpack=vue
212
+ ```
213
+ (or run `bundle exec rails webpacker:install:vue` on a Rails app already setup with webpacker).
214
+
215
+ The installer will add Vue and required libraries using yarn plus
216
+ any changes to the configuration files. An example component will
217
+ also be added to your project in `app/javascript` so that you can
218
+ experiment Vue right away.
219
+
220
+
221
+ ### Elm
222
+
223
+ To use Webpacker with [Elm](http://elm-lang.org), create a
224
+ new Rails 5.1+ app using `--webpack=elm` option:
225
+
226
+ ```
227
+ # Rails 5.1+
228
+ rails new myapp --webpack=elm
229
+ ```
230
+
231
+ (or run `bundle exec rails webpacker:install:elm` on a Rails app already setup with webpacker).
232
+
233
+ The Elm library and core packages will be added via Yarn and Elm itself.
234
+ An example `Main.elm` app will also be added to your project in `app/javascript`
235
+ so that you can experiment with Elm right away.
236
+
237
+
238
+ ## Paths
239
+
240
+ By default, webpacker ships with simple conventions for where the javascript
241
+ app files and compiled webpack bundles will go in your rails app,
242
+ but all these options are configurable from `config/webpacker.yml` file.
243
+
244
+ The configuration for what Webpack is supposed to compile by default rests
245
+ on the convention that every file in `app/javascript/packs/*`**(default)**
246
+ or whatever path you set for `source_entry_path` in the `webpacker.yml` configuration
247
+ is turned into their own output files (or entry points, as Webpack calls it). Therefore you don't want to put anything inside `packs` directory that you do want to be
248
+ an entry file. As a rule thumb, put all files your want to link in your views inside
249
+ "packs" directory and keep everything else under `app/javascript`.
250
+
251
+ Suppose you want to change the source directory from `app/javascript`
252
+ to `frontend` and output to `assets/packs`. This is how you would do it:
253
+
254
+ ```yml
255
+ # config/webpacker.yml
256
+ source_path: frontend
257
+ source_entry_path: packs
258
+ public_output_path: assets/packs # outputs to => public/assets/packs
259
+ ```
260
+
261
+ Similarly you can also control and configure `webpack-dev-server` settings from `config/webpacker.yml` file:
262
+
263
+ ```yml
264
+ # config/webpacker.yml
265
+ development:
266
+ dev_server:
267
+ host: localhost
268
+ port: 3035
269
+ ```
270
+
271
+ If you have `hmr` turned to true, then the `stylesheet_pack_tag` generates no output, as you will want to configure your styles to be inlined in your JavaScript for hot reloading. During production and testing, the `stylesheet_pack_tag` will create the appropriate HTML tags.
272
+
273
+
274
+ ### Resolved
275
+
276
+ If you are adding webpacker to an existing app that has most of the assets inside
277
+ `app/assets` or inside an engine and you want to share that
278
+ with webpack modules then you can use `resolved_paths`
279
+ option available in `config/webpacker.yml`, which lets you
280
+ add additional paths webpack should lookup when resolving modules:
281
+
282
+ ```yml
283
+ resolved_paths: ['app/assets']
284
+ ```
285
+
286
+ You can then import them inside your modules like so:
287
+
288
+ ```js
289
+ // Note it's relative to parent directory i.e. app/assets
290
+ import 'stylesheets/main'
291
+ import 'images/rails.png'
292
+ ```
293
+
294
+ **Note:** Please be careful when adding paths here otherwise it
295
+ will make the compilation slow, consider adding specific paths instead of
296
+ whole parent directory if you just need to reference one or two modules
297
+
298
+
299
+ ### Watched
300
+
301
+ By default, the lazy compilation is cached until a file is changed under
302
+ tracked paths. You can configure the paths tracked
303
+ by adding new paths to `watched_paths` array, much like rails `autoload_paths`:
304
+
305
+ ```rb
306
+ # config/initializers/webpacker.rb
307
+ # or config/application.rb
308
+ Webpacker::Compiler.watched_paths << 'bower_components'
309
+ ```
310
+
311
+
312
+ ## Deployment
313
+
314
+ Webpacker hooks up a new `webpacker:compile` task to `assets:precompile`, which gets run whenever you run `assets:precompile`. If you are not using sprockets you
315
+ can manually trigger `NODE_ENV=production bundle exec rails webpacker:compile`
316
+ during your app deploy.
317
+
318
+
319
+ ## Docs
320
+
321
+ You can find more detailed guides under [docs](./docs).
322
+
323
+
324
+ ## License
325
+ Webpacker is released under the [MIT License](https://opensource.org/licenses/MIT).