Skip to content

Commit a305177

Browse files
committedJul 19, 2020
feat: modify generators and update readme
1 parent a61f8af commit a305177

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed
 

‎README.md

+17-8
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ gem 'snowpacker'
2525

2626
Then run
2727

28-
$ bin/rails g snowpacker
28+
```
29+
bin/rails g snowpacker
30+
```
2931

3032
### Development
3133

3234
Currently `snowpacker` is not integrated with `rails s` so you need a process manager like [foreman]() to run both `rails s` and `snowpack`.
3335

3436
Create `Procfile.dev`, with the following content:
3537

36-
```
38+
```bash
3739
web: bin/rails s
3840
snowpacker: bin/rails snowpacker:serve
3941
```
@@ -46,21 +48,28 @@ Gem hooks up to the `assets:precompile` and `assets:clobber`, so no special setu
4648

4749
You can start snowpacker's compilation process manually by running
4850

49-
rake snowpacker:compile
51+
```bash
52+
rake snowpacker:compile
53+
```
5054

5155
### Including in views
5256

5357
Use Rails generic helpers to include assets in your views
5458

55-
javascript_include_tag '/snowpacks/application'
56-
stylesheet_link_tag '/snowpacks/application'
59+
```ruby
60+
<%= javascript_snowpack_tag 'application' %> # => snowpacks/javascript
61+
<%= stylesheet_snowpack_tag 'application' %> # => snowpacks/stylesheets
62+
```
5763

5864
### Configuration
5965

60-
After running generator, configuration can be found in config/initializers/snowpacker.rb.
66+
After running generator, the configuration file can be found in
67+
`config/initializers/snowpacker.rb`
6168

62-
config.snowpacker.entry_points = %w(app/javascript/application.js)
63-
config.snowpacker.destination = 'public/snowpacks'
69+
```ruby
70+
config.snowpacker.entry_points = %w(app/javascript/snowpacks/application.js)
71+
config.snowpacker.destination = 'snowpacks'
72+
```
6473

6574
## Changelog
6675

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Rails.application.config.snowpacker do |snowpacker|
2+
snowpacker.entry_points = %w(app/javascript/snowpacks/application.js)
3+
snowpacker.destination = 'snowpacks'
4+
end

‎examples/railsapp/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"devDependencies": {
1616
"@snowpack/plugin-babel": "^1.4.0",
1717
"@snowpack/plugin-parcel": "^1.3.0",
18+
"parcel-bundler": "^1.12.4",
1819
"snowpack": "^2.6.4",
1920
"webpack-dev-server": "^3.11.0"
2021
}

‎examples/railsapp/yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -4969,7 +4969,7 @@ pako@~1.0.5:
49694969
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf"
49704970
integrity sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==
49714971

4972-
parcel-bundler@^1.0.0:
4972+
parcel-bundler@^1.0.0, parcel-bundler@^1.12.4:
49734973
version "1.12.4"
49744974
resolved "https://registry.yarnpkg.com/parcel-bundler/-/parcel-bundler-1.12.4.tgz#31223f4ab4d00323a109fce28d5e46775409a9ee"
49754975
integrity sha512-G+iZGGiPEXcRzw0fiRxWYCKxdt/F7l9a0xkiU4XbcVRJCSlBnioWEwJMutOCCpoQmaQtjB4RBHDGIHN85AIhLQ==

‎lib/snowpacker/rails/snowpacker_generator.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ def create_initializer_file
1414
end
1515

1616
def add_snowpack
17-
`yarn add snowpack parcel-bundler \
18-
@snowpack/plugin-babel @snowpack/plugin-parcel`
17+
`yarn add -D snowpack \
18+
parcel-bundler \
19+
@snowpack/plugin-babel \
20+
@snowpack/plugin-parcel`
1921
end
2022
end

0 commit comments

Comments
 (0)
Please sign in to comment.