Skip to content

Commit 889f241

Browse files
committed
feat: add an example of using stylesheet link tags
1 parent 0b7bffc commit 889f241

3 files changed

Lines changed: 24 additions & 10 deletions

File tree

README.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
## WORK IN PROGRESS
44

5-
Progress can be seen on the `development` branch. Right now, this is a just a fork.
5+
Progress can be seen on the `development` branch.
66

77
[![Gem Version](https://badge.fury.io/rb/snowpacker.svg)](https://badge.fury.io/rb/snowpacker)
88
[![Maintainability](https://api.codeclimate.com/v1/badges/4b0a3f36a6b1970a88e5/maintainability)](https://codeclimate.com/github/ParamagicDev/snowpacker/maintainability)
99

10-
Gem integrates [snowpack](https://snowpack.dev/) JS module bundler into
10+
This gem integrates the [snowpack](https://snowpack.dev/) JS module bundler into
1111
your Rails application. It is inspired by gems such as
1212
[breakfast](https://github.com/devlocker/breakfast) /
13-
[webpacker](https://github.com/rails/webpacker) and is a fork off of
13+
[webpacker](https://github.com/rails/webpacker) started as a fork of
1414
[parcel-rails](https://github.com/michaldarda/parcel-rails)
1515

1616
This is not meant to be a 1:1 replacement of Webpacker.
@@ -25,23 +25,32 @@ gem 'snowpacker'
2525

2626
Then run
2727

28-
```
28+
```bash
2929
bin/rails g snowpacker
3030
```
3131

3232
### Development
3333

34-
Currently `snowpacker` is not integrated with `rails s` so you need a process manager like [foreman]() to run both `rails s` and `snowpack`.
34+
Currently `snowpacker` is not integrated with `rails s` so you need a process manager like [foreman](https://github.com/ddollar/foreman) to run both `rails s` and `snowpack`.
3535

3636
Create `Procfile.dev`, with the following content:
3737

3838
```bash
3939
web: bin/rails s
40-
snowpacker: bin/rails snowpacker:serve
40+
snowpacker: bin/rails snowpacker:dev
4141
```
4242

4343
Then run `foreman start -f Procfile.dev`
4444

45+
Alternatively, you can run:
46+
47+
```
48+
rails server
49+
rails snowpacker:dev
50+
```
51+
52+
in 2 different terminals.
53+
4554
### Production
4655

4756
Gem hooks up to the `assets:precompile` and `assets:clobber`, so no special setup is required.
@@ -50,15 +59,19 @@ You can start snowpacker's compilation process manually by running
5059

5160
```bash
5261
rails snowpacker:compile
62+
63+
# OR
64+
65+
rails snowpacker:build
5366
```
5467

5568
### Including in views
5669

5770
Use Rails generic helpers to include assets in your views
5871

5972
```ruby
60-
<%= javascript_snowpack_tag 'application' %> # => snowpacks/javascript
61-
<%= stylesheet_snowpack_tag 'application' %> # => snowpacks/stylesheets
73+
<%= javascript_include_tag '/snowpacks/application' %>
74+
<%= stylesheet_snowpack_tag '/snowpacks/application' %>
6275
```
6376

6477
### Configuration
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
div {
2-
background: red;
1+
body {
2+
background: yellow;
33
}

examples/railsapp/app/views/layouts/application.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<%= csp_meta_tag %>
77

88
<%= javascript_include_tag '/snowpacks/packs/application', type: "module" %>
9+
<%= stylesheet_link_tag '/snowpacks/stylesheets/index' %>
910

1011
<script>window.HMR_WEBSOCKET_URL = "ws://localhost:3000"</script>
1112
</head>

0 commit comments

Comments
 (0)