webpacker 1.0 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc.js +14 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +124 -0
- data/.travis.yml +24 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +6 -6
- data/README.md +126 -19
- data/lib/install/angular.rb +18 -0
- data/lib/install/bin/webpack-dev-server.tt +23 -12
- data/lib/install/bin/webpack-watcher.tt +3 -0
- data/lib/install/bin/webpack.tt +33 -7
- data/lib/install/config/.postcssrc.yml +4 -0
- data/lib/install/config/loaders/core/assets.js +12 -0
- data/lib/install/config/loaders/core/babel.js +10 -0
- data/lib/install/config/loaders/core/coffee.js +4 -0
- data/lib/install/config/loaders/core/erb.js +9 -0
- data/lib/install/config/loaders/core/sass.js +9 -0
- data/lib/install/config/loaders/installers/angular.js +4 -0
- data/lib/install/config/loaders/installers/react.js +11 -0
- data/lib/install/config/loaders/installers/vue.js +10 -0
- data/lib/install/config/webpack/configuration.js +21 -0
- data/lib/install/config/webpack/development.js +16 -0
- data/lib/install/config/webpack/development.server.js +17 -0
- data/lib/install/config/webpack/development.server.yml +4 -0
- data/lib/install/config/webpack/paths.yml +19 -0
- data/lib/install/config/webpack/production.js +20 -0
- data/lib/install/config/webpack/shared.js +51 -0
- data/lib/install/{angular → examples/angular}/hello_angular.js +1 -1
- data/lib/install/{angular → examples/angular}/hello_angular/app/app.component.ts +0 -0
- data/lib/install/{angular → examples/angular}/hello_angular/app/app.module.ts +0 -0
- data/lib/install/{angular → examples/angular}/hello_angular/index.ts +0 -0
- data/lib/install/{angular → examples/angular}/hello_angular/polyfills.ts +0 -0
- data/lib/install/{angular → examples/angular}/tsconfig.json +0 -0
- data/lib/install/examples/react/.babelrc +3 -0
- data/lib/install/examples/react/hello_react.jsx +25 -0
- data/lib/install/examples/vue/app.vue +22 -0
- data/lib/install/examples/vue/hello_vue.js +19 -0
- data/lib/install/javascript/packs/application.js +1 -0
- data/lib/install/react.rb +15 -0
- data/lib/install/template.rb +20 -14
- data/lib/install/vue.rb +15 -0
- data/lib/tasks/installers.rake +21 -0
- data/lib/tasks/webpacker.rake +14 -107
- data/lib/tasks/webpacker/compile.rake +29 -0
- data/lib/tasks/webpacker/install.rake +12 -0
- data/lib/tasks/webpacker/verify_install.rake +16 -0
- data/lib/tasks/webpacker/yarn_install.rake +6 -0
- data/lib/webpacker.rb +1 -1
- data/lib/webpacker/configuration.rb +42 -0
- data/lib/webpacker/file_loader.rb +24 -0
- data/lib/webpacker/helper.rb +32 -3
- data/lib/webpacker/manifest.rb +29 -0
- data/lib/webpacker/railtie.rb +6 -16
- data/lib/webpacker/version.rb +3 -0
- data/package.json +28 -0
- data/webpacker.gemspec +15 -12
- data/yarn.lock +1014 -0
- metadata +50 -20
- data/lib/install/config/development.js +0 -24
- data/lib/install/config/production.js +0 -16
- data/lib/install/config/shared.js +0 -70
- data/lib/install/react/.babelrc +0 -3
- data/lib/install/react/hello_react.js +0 -16
- data/lib/webpacker/digests.rb +0 -42
- data/lib/webpacker/source.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afb4934952e44753c407df428b480d135304df59
|
4
|
+
data.tar.gz: f124edb9f58ce86a53dbea607abaea20899c8ab4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d446150ede6cbec18cd3117b85ff8afa66223b8d68f33db1530206279b3226f6938382fd37d2bee8c5bca31f8136161596541d9c2e6e69e0163e4d6ce85ee05
|
7
|
+
data.tar.gz: 9e8c65dd9322341a790f073c55146c6305aab8210260320d4e6834581fccef83ca0312bc2bffb59e9764f5693a6acef4d099a0c97fe928d7f5bb4532c99d4373
|
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
CHANGED
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
|
+
Style/CaseIndentation:
|
22
|
+
Enabled: true
|
23
|
+
|
24
|
+
# Align comments with method definitions.
|
25
|
+
Style/CommentIndentation:
|
26
|
+
Enabled: true
|
27
|
+
|
28
|
+
# No extra empty lines.
|
29
|
+
Style/EmptyLines:
|
30
|
+
Enabled: true
|
31
|
+
|
32
|
+
# In a regular class definition, no empty lines around the body.
|
33
|
+
Style/EmptyLinesAroundClassBody:
|
34
|
+
Enabled: true
|
35
|
+
|
36
|
+
# In a regular method definition, no empty lines around the body.
|
37
|
+
Style/EmptyLinesAroundMethodBody:
|
38
|
+
Enabled: true
|
39
|
+
|
40
|
+
# In a regular module definition, no empty lines around the body.
|
41
|
+
Style/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
|
+
Style/IndentationConsistency:
|
51
|
+
Enabled: true
|
52
|
+
EnforcedStyle: rails
|
53
|
+
|
54
|
+
# Two spaces, no tabs (for indentation).
|
55
|
+
Style/IndentationWidth:
|
56
|
+
Enabled: true
|
57
|
+
|
58
|
+
Style/SpaceAfterColon:
|
59
|
+
Enabled: true
|
60
|
+
|
61
|
+
Style/SpaceAfterComma:
|
62
|
+
Enabled: true
|
63
|
+
|
64
|
+
Style/SpaceAroundEqualsInParameterDefault:
|
65
|
+
Enabled: true
|
66
|
+
|
67
|
+
Style/SpaceAroundKeyword:
|
68
|
+
Enabled: true
|
69
|
+
|
70
|
+
Style/SpaceAroundOperators:
|
71
|
+
Enabled: true
|
72
|
+
|
73
|
+
Style/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
|
+
Style/SpaceBeforeBlockBraces:
|
82
|
+
Enabled: true
|
83
|
+
|
84
|
+
# Use `foo { bar }` not `foo {bar}`.
|
85
|
+
Style/SpaceInsideBlockBraces:
|
86
|
+
Enabled: true
|
87
|
+
|
88
|
+
# Use `{ a: 1 }` not `{a:1}`.
|
89
|
+
Style/SpaceInsideHashLiteralBraces:
|
90
|
+
Enabled: true
|
91
|
+
|
92
|
+
Style/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
|
+
Style/Tab:
|
102
|
+
Enabled: true
|
103
|
+
|
104
|
+
# Blank lines should not have any spaces.
|
105
|
+
Style/TrailingBlankLines:
|
106
|
+
Enabled: true
|
107
|
+
|
108
|
+
# No trailing whitespace.
|
109
|
+
Style/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,24 @@
|
|
1
|
+
sudo: required
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.2.6
|
5
|
+
|
6
|
+
services:
|
7
|
+
- docker
|
8
|
+
|
9
|
+
cache:
|
10
|
+
bundler: true
|
11
|
+
directories:
|
12
|
+
- node_modules
|
13
|
+
yarn: true
|
14
|
+
|
15
|
+
install:
|
16
|
+
- gem install rubocop
|
17
|
+
- nvm install node
|
18
|
+
- node -v
|
19
|
+
- npm i -g yarn
|
20
|
+
- yarn
|
21
|
+
|
22
|
+
script:
|
23
|
+
- yarn lint
|
24
|
+
- rubocop
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
webpacker (0
|
5
|
-
activesupport (>=
|
4
|
+
webpacker (1.0)
|
5
|
+
activesupport (>= 4.2)
|
6
6
|
multi_json (~> 1.2)
|
7
|
-
railties (>=
|
7
|
+
railties (>= 4.2)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
@@ -28,9 +28,9 @@ GEM
|
|
28
28
|
minitest (~> 5.1)
|
29
29
|
tzinfo (~> 1.1)
|
30
30
|
builder (3.2.3)
|
31
|
-
concurrent-ruby (1.0.
|
31
|
+
concurrent-ruby (1.0.5)
|
32
32
|
erubis (2.7.0)
|
33
|
-
i18n (0.8.
|
33
|
+
i18n (0.8.1)
|
34
34
|
loofah (2.0.3)
|
35
35
|
nokogiri (>= 1.5.9)
|
36
36
|
method_source (0.8.2)
|
@@ -55,7 +55,7 @@ GEM
|
|
55
55
|
thor (>= 0.18.1, < 2.0)
|
56
56
|
rake (12.0.0)
|
57
57
|
thor (0.19.4)
|
58
|
-
thread_safe (0.3.
|
58
|
+
thread_safe (0.3.6)
|
59
59
|
tzinfo (1.2.2)
|
60
60
|
thread_safe (~> 0.1)
|
61
61
|
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Webpacker
|
2
|
+
![travis-ci status](https://api.travis-ci.org/rails/webpacker.svg?branch=master)
|
2
3
|
|
3
4
|
Webpacker makes it easy to use the JavaScript preprocessor and bundler [Webpack](https://webpack.github.io)
|
4
5
|
to manage application-like JavaScript in Rails. It coexists with the asset pipeline,
|
@@ -10,11 +11,11 @@ that's been made default from that version forward.
|
|
10
11
|
|
11
12
|
## Installation
|
12
13
|
|
13
|
-
Webpacker is currently compatible with Rails
|
14
|
+
Webpacker is currently compatible with Rails 4.2+, but there's no guarantee it will still be
|
14
15
|
in the future.
|
15
16
|
|
16
17
|
You can either make use of Webpacker during setup of a new application with `--webpack`
|
17
|
-
or you can add the gem and run
|
18
|
+
or you can add the gem and run `./bin/rails webpacker:install` in an existing application.
|
18
19
|
|
19
20
|
As the rubygems version isn't promised to be kept up to date until the release of Rails 5.1, you may want to include the gem directly from GitHub:
|
20
21
|
|
@@ -22,6 +23,8 @@ As the rubygems version isn't promised to be kept up to date until the release o
|
|
22
23
|
gem 'webpacker', github: 'rails/webpacker'
|
23
24
|
```
|
24
25
|
|
26
|
+
You can also see a list of available commands by running `./bin/rails webpacker`
|
27
|
+
|
25
28
|
## Binstubs
|
26
29
|
|
27
30
|
Webpacker ships with three binstubs: `./bin/webpack`, `./bin/webpack-watcher` and `./bin/webpack-dev-server`.
|
@@ -39,9 +42,7 @@ If you'd rather not have to run the two processes separately by hand, you can us
|
|
39
42
|
|
40
43
|
Alternatively, you can run `./bin/webpack-dev-server`. This will launch a
|
41
44
|
[Webpack Dev Server](https://webpack.github.io/docs/webpack-dev-server.html) listening on http://localhost:8080/
|
42
|
-
serving your pack files.
|
43
|
-
`config.x.webpacker[:dev_server_host]` in your `config/environments/development.rb` to tell Webpacker to load
|
44
|
-
your packs from the Webpack Dev Server. This setup allows you to leverage advanced Webpack features, such
|
45
|
+
serving your pack files. This setup allows you to leverage advanced Webpack features, such
|
45
46
|
as [Hot Module Replacement](https://webpack.github.io/docs/hot-module-replacement-with-webpack.html).
|
46
47
|
|
47
48
|
|
@@ -58,11 +59,6 @@ as Webpack calls it).
|
|
58
59
|
|
59
60
|
Let's say you're building a calendar. Your structure could look like this:
|
60
61
|
|
61
|
-
```erb
|
62
|
-
<%# app/views/layout/application.html.erb %>
|
63
|
-
<%= javascript_pack_tag 'calendar' %>
|
64
|
-
```
|
65
|
-
|
66
62
|
```js
|
67
63
|
// app/javascript/packs/calendar.js
|
68
64
|
require('calendar')
|
@@ -71,19 +67,108 @@ require('calendar')
|
|
71
67
|
```
|
72
68
|
app/javascript/calendar/index.js // gets loaded by require('calendar')
|
73
69
|
app/javascript/calendar/components/grid.jsx
|
70
|
+
app/javascript/calendar/styles/grid.sass
|
74
71
|
app/javascript/calendar/models/month.js
|
75
72
|
```
|
76
73
|
|
77
|
-
|
78
|
-
|
74
|
+
```erb
|
75
|
+
<%# app/views/layout/application.html.erb %>
|
76
|
+
<%= javascript_pack_tag 'calendar' %>
|
77
|
+
<%= stylesheet_pack_tag 'calendar' %>
|
78
|
+
```
|
79
|
+
|
80
|
+
But it could also look a million other ways.
|
81
|
+
|
82
|
+
## Advanced Configuration
|
83
|
+
|
84
|
+
By default, webpacker offers simple conventions for where the webpack configs, javascript app files and compiled webpack bundles will go in your rails app,
|
85
|
+
but all these options are configurable from `config/webpack/paths.yml` file.
|
86
|
+
|
87
|
+
```yml
|
88
|
+
# config/webpack/paths.yml
|
89
|
+
source: app/javascript
|
90
|
+
entry: packs
|
91
|
+
output: public
|
92
|
+
config: config/webpack
|
93
|
+
node_modules: node_modules
|
94
|
+
```
|
95
|
+
|
96
|
+
*Note:* Behind the scenes, webpacker will use same `entry` directory name inside `output`
|
97
|
+
directory to emit bundles. For ex, `public/packs`
|
98
|
+
|
99
|
+
Similary, you can also control and configure `webpack-dev-server` settings from
|
100
|
+
`config/webpack/development.server.yml` file
|
101
|
+
|
102
|
+
```yml
|
103
|
+
# config/webpack/development.server.yml
|
104
|
+
enabled: true
|
105
|
+
host: localhost
|
106
|
+
port: 8080
|
107
|
+
```
|
108
|
+
|
109
|
+
By default, `webpack-dev-server` uses `output` option specified in
|
110
|
+
`paths.yml` as `contentBase`.
|
111
|
+
|
112
|
+
**Note:** Don't forget to disable `webpack-dev-server` incase you are using
|
113
|
+
`./bin/webpack-watcher` to serve assets in development mode otherwise
|
114
|
+
you will get 404 for assets because the helper tag will use webpack-dev-server url
|
115
|
+
to serve assets instead of public directory.
|
79
116
|
|
117
|
+
## Linking to static assets
|
118
|
+
|
119
|
+
Static assets like images, fonts and stylesheets support is enabled out-of-box so, you can link them into your javascript app code and have them compiled automatically.
|
120
|
+
|
121
|
+
```js
|
122
|
+
// React component example
|
123
|
+
// app/javascripts/packs/hello_react.jsx
|
124
|
+
import React from 'react'
|
125
|
+
import ReactDOM from 'react-dom'
|
126
|
+
import helloIcon from '../hello_react/images/icon.png'
|
127
|
+
import './hello-react.sass'
|
128
|
+
|
129
|
+
const Hello = props => (
|
130
|
+
<div className="hello-react">
|
131
|
+
<img src={helloIcon} alt="hello-icon" />
|
132
|
+
<p>Hello {props.name}!</p>
|
133
|
+
</div>
|
134
|
+
)
|
135
|
+
```
|
136
|
+
|
137
|
+
under the hood webpack uses [extract-text-webpack-plugin](https://github.com/webpack-contrib/extract-text-webpack-plugin) plugin to extract all the referenced styles and compile it into a separate `[pack_name].css` bundle so that within your view you can use the `stylesheet_pack_tag` helper,
|
138
|
+
|
139
|
+
```erb
|
140
|
+
<%= stylesheet_pack_tag 'hello_react' %>
|
141
|
+
```
|
142
|
+
|
143
|
+
## Getting asset path
|
144
|
+
|
145
|
+
Webpacker provides `asset_pack_path` helper to get the path of any given asset that's been compiled by webpack.
|
146
|
+
|
147
|
+
**For ex,** if you want to create a `<link rel="prefetch">` or `<img />`
|
148
|
+
for an asset used in your pack code you can reference them like this in your view,
|
149
|
+
|
150
|
+
```erb
|
151
|
+
<%= asset_pack_path 'hello_react.css' %>
|
152
|
+
<% # => "/packs/hello_react.css" %>
|
153
|
+
<img src="<%= asset_pack_path 'calendar.png' %>" />
|
154
|
+
<% # => <img src="/packs/calendar.png" /> %>
|
155
|
+
```
|
80
156
|
|
81
157
|
## Deployment
|
82
158
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
159
|
+
Webpacker hooks up a new `webpacker:compile` task to `assets:precompile`, which gets run whenever you run `assets:precompile`. The `javascript_pack_tag` and `stylesheet_pack_tag` helper method will automatically insert the correct HTML tag for compiled pack. Just like the asset pipeline does it. By default the output will look like this in different environments,
|
160
|
+
|
161
|
+
```html
|
162
|
+
<!-- In development mode with webpack-dev-server -->
|
163
|
+
<script src="http://localhost:8080/calendar.js"></script>
|
164
|
+
<link rel="stylesheet" media="screen" href="http://localhost:8080/calendar.css">
|
165
|
+
<!-- In development mode -->
|
166
|
+
<script src="/packs/calendar.js"></script>
|
167
|
+
<link rel="stylesheet" media="screen" href="/packs/calendar.css">
|
168
|
+
<!-- In production mode -->
|
169
|
+
<script src="/packs/calendar-0bd141f6d9360cf4a7f5.js"></script>
|
170
|
+
<link rel="stylesheet" media="screen" href="/packs/calendar-dc02976b5f94b507e3b6.css">
|
171
|
+
```
|
87
172
|
|
88
173
|
## Linking to sprockets assets
|
89
174
|
|
@@ -101,20 +186,42 @@ This is enabled by the `rails-erb-loader` loader rule in `config/webpack/shared.
|
|
101
186
|
|
102
187
|
## Ready for React
|
103
188
|
|
104
|
-
To use Webpacker with React, just create a new app with `rails new myapp --webpack=react` (or run `rails webpacker:install:react` on a Rails
|
189
|
+
To use Webpacker with React, just create a new app with `rails new myapp --webpack=react` (or run `rails webpacker:install:react` on a Rails app already setup with webpacker), and all the relevant dependencies
|
105
190
|
will be added via yarn and changes to the configuration files made. Now you can create JSX files and
|
106
191
|
have them properly compiled automatically.
|
107
192
|
|
108
193
|
## Ready for Angular with TypeScript
|
109
194
|
|
110
|
-
To use Webpacker with Angular, just create a new app with `rails new myapp --webpack=angular` (or run `rails webpacker:install:angular` on a Rails
|
195
|
+
To use Webpacker with Angular, just create a new app with `rails new myapp --webpack=angular` (or run `rails webpacker:install:angular` on a Rails app already setup with webpacker). TypeScript support and the Angular core libraries will be added via yarn and changes to the configuration files made. An example component written in TypeScript is also added to your project in `app/javascript` so that you can experiment Angular right away.
|
196
|
+
|
197
|
+
## Ready for Vue
|
198
|
+
|
199
|
+
To use Webpacker with Vue, just create a new app with `rails new myapp --webpack=vue` (or run `rails webpacker:install:vue` on a Rails app already setup with webpacker). Vue and its supported libraries will be added via yarn and changes to the configuration files made. An example component is also added to your project in `app/javascript` so that you can experiment Vue right away.
|
200
|
+
|
201
|
+
## Troubleshooting
|
202
|
+
|
203
|
+
* If you get this error `ENOENT: no such file or directory - node-sass` on Heroku
|
204
|
+
or elsewhere during `assets:precompile` or `bundle exec rails webpacker:compile`
|
205
|
+
then you would need to rebuild node-sass. It's a bit weird error,
|
206
|
+
basically, it can't find the `node-sass` binary.
|
207
|
+
An easy solution is to create a postinstall hook - `npm rebuild node-sass` in
|
208
|
+
`package.json` and that will ensure `node-sass` is rebuild whenever
|
209
|
+
you install any new modules.
|
210
|
+
|
211
|
+
* If you get this error `Can't find hello_react.js in manifest.json`
|
212
|
+
when loading a view in browser it's because Webpack is still compiling packs.
|
213
|
+
Webpacker uses a `manifest.json` file to keep track of packs in all environments,
|
214
|
+
however since this file is generated after packs are compiled by webpack. So,
|
215
|
+
if you load a view in browser whilst webpack is compiling you will get this error.
|
216
|
+
Therefore, make sure webpack
|
217
|
+
(i.e `./bin/webpack-watcher` or `./bin/webpack-dev-server`) is running and has
|
218
|
+
completed the compilation successfully before loading a view.
|
111
219
|
|
112
220
|
## Wishlist
|
113
221
|
|
114
222
|
- Improve process for linking to assets compiled by sprockets - shouldn't need to specify
|
115
223
|
` <% helpers = ActionController::Base.helpers %>` at the beginning of each file
|
116
224
|
- Consider chunking setup
|
117
|
-
- Consider on-demand compiling with digests when digesting=true
|
118
225
|
|
119
226
|
## License
|
120
227
|
Webpacker is released under the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "webpacker/configuration"
|
2
|
+
|
3
|
+
puts "Copying angular loader to #{Webpacker::Configuration.config_path}/loaders"
|
4
|
+
copy_file "#{__dir__}/config/loaders/installers/angular.js", "config/webpack/loaders/angular.js"
|
5
|
+
|
6
|
+
puts "Copying angular example entry file to #{Webpacker::Configuration.entry_path}"
|
7
|
+
copy_file "#{__dir__}/examples/angular/hello_angular.js", "#{Webpacker::Configuration.entry_path}/hello_angular.js"
|
8
|
+
|
9
|
+
puts "Copying hello_angular app to #{Webpacker::Configuration.source_path}"
|
10
|
+
directory "#{__dir__}/examples/angular/hello_angular", "#{Webpacker::Configuration.source_path}/hello_angular"
|
11
|
+
|
12
|
+
puts "Copying tsconfig.json to the Rails root directory for typescript"
|
13
|
+
copy_file "#{__dir__}/examples/angular/tsconfig.json", "tsconfig.json"
|
14
|
+
|
15
|
+
puts "Installing all angular dependencies"
|
16
|
+
run "./bin/yarn add typescript ts-loader core-js zone.js rxjs @angular/core @angular/common @angular/compiler @angular/platform-browser @angular/platform-browser-dynamic"
|
17
|
+
|
18
|
+
puts "Webpacker now supports angular.js and typescript 🎉"
|