You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: guides/source/webpacker.md
+4-24Lines changed: 4 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,9 @@ To use Webpacker, you must install the Yarn package manager, version 1.x or up,
51
51
52
52
NOTE: Webpacker depends on NPM and Yarn. NPM, the Node package manager registry, is the primary repository for publishing and downloading open-source JavaScript projects, both for Node.js and browser runtimes. It is analogous to rubygems.org for Ruby gems. Yarn is a command-line utility that enables the installation and management of JavaScript dependencies, much like Bundler does for Ruby.
53
53
54
-
Webpacker is installed by default in Rails 6.0 and up. You can install it with a new project in some older versions by adding `--webpack` to the `rails new` command. Webpacker can be added in an existing project by running `bin/rails webpacker:install`. This installation command creates the following local files:
54
+
To include Webpacker in a new project, add `--webpack` to the `rails new` command. To add Webpacker to an existing project, add the `webpacker` gem to the project's `Gemfile`, run `bundle install`, and then run `bin/rails webpacker:install`.
55
+
56
+
Installing Webpacker creates the following local files:
@@ -64,28 +66,6 @@ Webpacker is installed by default in Rails 6.0 and up. You can install it with a
64
66
65
67
The installation also calls the `yarn` package manager, creates a `package.json` file with a basic set of packages listed, and uses Yarn to install these dependencies.
66
68
67
-
### Integrating Frameworks with Webpacker
68
-
69
-
Webpacker also contains support for many popular JavaScript frameworks and tools. Typically, these are installed either when the application is created with something like `rails new myapp --webpack=<framework_name>` or with a separate command-line task, like `rails webpacker:install:<framework_name>`.
70
-
71
-
These integrations typically install the set of NPM packages needed to get started with the framework or tool, a "hello world" page to show that it works, and any other webpack loaders or transformations needed to compile the tool. The supported frameworks and tools are:
72
-
73
-
INFO. It's possible to install frameworks not included in this list. These are basic integrations of popular choices.
|Angular |`bin/rails webpacker:install:angular`|Sets up Angular and TypeScript |
78
-
|CoffeeScript |`bin/rails webpacker:install:coffee`|Sets up CoffeeScript |
79
-
|Elm |`bin/rails webpacker:install:elm`|Sets up Elm |
80
-
|ERB |`bin/rails webpacker:install:erb`|Sets up ERB support on your JavaScript files |
81
-
|React |`bin/rails webpacker:install:react`|Sets up ReactJS |
82
-
|Stimulus |`bin/rails webpacker:install:stimulus`|Sets up StimulusJS |
83
-
|Svelte |`bin/rails webpacker:install:svelte`|Sets up Svelte JS |
84
-
|TypeScript |`bin/rails webpacker:install:typescript`|Sets up TypeScript for your project using Babel's TypeScript support|
85
-
|Vue |`bin/rails webpacker:install:vue`|Sets up VueJS |
86
-
87
-
For more information about the existing integrations, consult the [README](https://github.com/rails/webpacker#integrations).
88
-
89
69
Usage
90
70
-----
91
71
@@ -180,7 +160,7 @@ You can also access the image by directly referencing the file from a CSS file i
180
160
181
161
### Webpacker in Rails Engines
182
162
183
-
As of Webpacker version 5, Webpacker is not "engine-aware," which means Webpacker does not have feature-parity with Sprockets when it comes to using within Rails engines. The [Webpacker engine guides](https://github.com/rails/webpacker/blob/master/docs/engines.md) provide some detailed workarounds to add Webpacker-support and developing locally against an engine with Webpacker.
163
+
As of Webpacker version 6, Webpacker is not "engine-aware," which means Webpacker does not have feature-parity with Sprockets when it comes to using within Rails engines.
184
164
185
165
Gem authors of Rails engines who wish to support consumers using Webpacker are encouraged to distribute frontend assets as an NPM package in addition to the gem itself and provide instructions (or an installer) to demonstrate how host apps should integrate. A good example of this approach is [Alchemy CMS](https://github.com/AlchemyCMS/alchemy_cms).
0 commit comments