activeadmin-tom_select 4.1.2 → 4.2.0.beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Appraisals +2 -2
- data/CHANGELOG.md +12 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +146 -102
- data/README.md +1 -1
- data/activeadmin-tom_select.gemspec +1 -0
- data/docs/activeadmin-4-asset-setup.md +171 -0
- data/docs/activeadmin-tailwind-4.md +125 -0
- data/docs/guide-update-your-app.md +89 -356
- data/docs/setup-activeadmin-app.md +69 -492
- data/docs/setup-activeadmin-gem.md +83 -449
- data/gemfiles/rails_7.x_active_admin_4.x.gemfile +2 -1
- data/gemfiles/rails_7.x_active_admin_4.x.gemfile.lock +158 -116
- data/gemfiles/rails_8.x_active_admin_4.x.gemfile +2 -1
- data/gemfiles/rails_8.x_active_admin_4.x.gemfile.lock +145 -101
- data/lib/activeadmin/tom_select/option_collection.rb +4 -6
- data/lib/activeadmin/tom_select/select_input_extension.rb +15 -7
- data/lib/activeadmin/tom_select/version.rb +1 -1
- data/npm-package/package.json +1 -1
- data/spec/features/end_to_end_spec.rb +2 -2
- data/spec/features/input_errors_spec.rb +1 -3
- data/spec/features/options_dsl_spec.rb +6 -6
- data/spec/internal/Gemfile +1 -0
- data/spec/internal/Gemfile.lock +152 -107
- data/spec/internal/app/assets/stylesheets/active_admin.tailwind.css +8 -5
- data/spec/internal/bin/tailwindcss +27 -0
- data/spec/internal/lib/tasks/active_admin.rake +9 -4
- data/spec/internal/package-lock.json +15 -1371
- data/spec/internal/package.json +1 -2
- data/{docs/tailwind-4/tailwind-active_admin.config.js → spec/internal/tailwind-active_admin.config.mjs} +9 -4
- data/spec/internal/yarn.lock +128 -728
- metadata +21 -23
- data/docs/activeadmin-4-detailed-reference.md +0 -932
- data/docs/activeadmin-4-gem-migration-guide.md +0 -313
- data/docs/combustion.md +0 -213
- data/docs/fail.png +0 -0
- data/docs/normal.png +0 -0
- data/docs/propshaft-readme.md +0 -320
- data/docs/propshaft-upgrade.md +0 -484
- data/docs/tailwind/blog-page.md +0 -341
- data/docs/tailwind/upgrade-guide-enhanced.md +0 -438
- data/docs/tailwind/upgrade-guide.md +0 -416
- data/docs/tailwind-4/active_admin.rake +0 -38
- data/docs/tailwind-4/active_admin.tailwind.css +0 -415
- data/docs/test-app-change.md +0 -154
- data/docs/test-environment-fixes.md +0 -58
- data/docs/update-tom-select.md +0 -348
data/docs/propshaft-readme.md
DELETED
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
# Propshaft: A Modern Asset Pipeline for Rails
|
|
2
|
-
|
|
3
|
-
Propshaft is an asset pipeline library for Rails. It's built for an era where bundling assets to save on HTTP connections is no longer urgent, where JavaScript and CSS are either compiled by dedicated Node.js bundlers or served directly to the browsers, and where increases in bandwidth have made the need for minification less pressing. These factors allow for a dramatically simpler and faster asset pipeline compared to previous options, like [Sprockets](https://github.com/rails/sprockets-rails).
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
1. [Overview](#overview)
|
|
8
|
-
2. [Architecture](#architecture)
|
|
9
|
-
3. [Asset Serving in Development/Test Mode](#asset-serving-in-developmenttest-mode)
|
|
10
|
-
4. [Configuration and Asset Paths](#configuration-and-asset-paths)
|
|
11
|
-
5. [Test Environment Specifics](#test-environment-specifics)
|
|
12
|
-
6. [JavaScript and CSS Bundling Integration](#javascript-and-css-bundling-integration)
|
|
13
|
-
7. [Common Patterns and Best Practices](#common-patterns-and-best-practices)
|
|
14
|
-
|
|
15
|
-
## Overview
|
|
16
|
-
|
|
17
|
-
So that's what Propshaft doesn't do. Here's what it does provide:
|
|
18
|
-
|
|
19
|
-
1. **Configurable load path**: You can register directories from multiple places in your app and gems, and reference assets from all of these paths as though they were one.
|
|
20
|
-
1. **Digest stamping**: All assets in the load path will be copied (or compiled) in a precompilation step for production that also stamps all of them with a digest hash, so you can use long-expiry cache headers for better performance. The digested assets can be referred to through their logical path because the processing leaves a manifest file that provides a way to translate.
|
|
21
|
-
1. **Development server**: There's no need to precompile the assets in development. You can refer to them via the same asset_path helpers and they'll be served by a development server.
|
|
22
|
-
1. **Basic compilers**: Propshaft was explicitly not designed to provide full transpiler capabilities. You can get that better elsewhere. But it does offer a simple input->output compiler setup that by default is used to translate `url(asset)` function calls in CSS to `url(digested-asset)` instead and source mapping comments likewise.
|
|
23
|
-
|
|
24
|
-
## Architecture
|
|
25
|
-
|
|
26
|
-
### Core Components
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
Propshaft::Assembly
|
|
30
|
-
├── LoadPath # Asset discovery and caching
|
|
31
|
-
├── Resolver # Path resolution (Dynamic/Static)
|
|
32
|
-
│ ├── Dynamic # Development/test mode
|
|
33
|
-
│ └── Static # Production with manifest
|
|
34
|
-
├── Server # Rack middleware for asset serving
|
|
35
|
-
├── Processor # Precompilation and digesting
|
|
36
|
-
├── Compilers # Asset transformation
|
|
37
|
-
└── Manifest # Asset mapping and integrity hashes
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### Key Classes
|
|
41
|
-
|
|
42
|
-
#### `Propshaft::Assembly`
|
|
43
|
-
Central coordinator that manages all components. Created during Rails initialization and accessible via `Rails.application.assets`.
|
|
44
|
-
|
|
45
|
-
```ruby
|
|
46
|
-
# Core assembly configuration
|
|
47
|
-
Rails.application.configure do
|
|
48
|
-
app.assets = Propshaft::Assembly.new(app.config.assets)
|
|
49
|
-
end
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
#### `Propshaft::LoadPath`
|
|
53
|
-
Manages asset discovery across multiple directories. Automatically includes:
|
|
54
|
-
- `app/assets/**/*` (application assets)
|
|
55
|
-
- `lib/assets/**/*` (library assets)
|
|
56
|
-
- `vendor/assets/**/*` (third-party assets)
|
|
57
|
-
- Engine assets from all loaded gems
|
|
58
|
-
|
|
59
|
-
#### `Propshaft::Resolver::Dynamic`
|
|
60
|
-
Used in development and test environments. Resolves assets on-demand without requiring precompilation.
|
|
61
|
-
|
|
62
|
-
#### `Propshaft::Resolver::Static`
|
|
63
|
-
Used in production. Relies on `.manifest.json` for fast asset resolution.
|
|
64
|
-
|
|
65
|
-
## Asset Serving in Development/Test Mode
|
|
66
|
-
|
|
67
|
-
### Dynamic Resolution Process
|
|
68
|
-
|
|
69
|
-
1. **Request Interception**: `Propshaft::Server` middleware catches requests to `/assets/*`
|
|
70
|
-
2. **Asset Discovery**: `LoadPath#find` searches configured paths for matching assets
|
|
71
|
-
3. **Compilation**: Assets pass through registered compilers
|
|
72
|
-
4. **Cache Headers**: Aggressive caching with ETags and immutable cache-control
|
|
73
|
-
5. **Response**: Compiled content served with appropriate MIME type
|
|
74
|
-
|
|
75
|
-
```ruby
|
|
76
|
-
# Server middleware in action (simplified)
|
|
77
|
-
def call(env)
|
|
78
|
-
if path.start_with?(@assembly.prefix) && (asset = @assembly.load_path.find(path))
|
|
79
|
-
[200, {
|
|
80
|
-
'Content-Type' => asset.content_type,
|
|
81
|
-
'ETag' => "\"#{asset.digest}\"",
|
|
82
|
-
'Cache-Control' => 'public, max-age=31536000, immutable'
|
|
83
|
-
}, [asset.compiled_content]]
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Cache Sweeping
|
|
89
|
-
|
|
90
|
-
In development/test, Propshaft monitors file changes:
|
|
91
|
-
|
|
92
|
-
```ruby
|
|
93
|
-
config.assets.sweep_cache = Rails.env.development?
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
When enabled, before each request:
|
|
97
|
-
1. File watcher checks for modifications
|
|
98
|
-
2. Asset cache cleared if changes detected
|
|
99
|
-
3. New assets discovered and cached
|
|
100
|
-
|
|
101
|
-
## Configuration and Asset Paths
|
|
102
|
-
|
|
103
|
-
### Default Configuration (from Railtie)
|
|
104
|
-
|
|
105
|
-
```ruby
|
|
106
|
-
config.assets.paths = [] # Auto-populated
|
|
107
|
-
config.assets.excluded_paths = [] # Paths to exclude
|
|
108
|
-
config.assets.version = "1" # Cache invalidation
|
|
109
|
-
config.assets.prefix = "/assets" # URL prefix
|
|
110
|
-
config.assets.server = Rails.env.development? || Rails.env.test?
|
|
111
|
-
config.assets.sweep_cache = Rails.env.development?
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Path Resolution Order
|
|
115
|
-
|
|
116
|
-
1. **Application paths**: `app/assets/**/*`
|
|
117
|
-
2. **Library paths**: `lib/assets/**/*`
|
|
118
|
-
3. **Vendor paths**: `vendor/assets/**/*`
|
|
119
|
-
4. **Engine paths**: From all loaded Rails engines/gems
|
|
120
|
-
|
|
121
|
-
Paths are automatically prioritized:
|
|
122
|
-
- Application assets take precedence over engine assets
|
|
123
|
-
- Later additions to load path have lower priority
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
## Installation
|
|
127
|
-
|
|
128
|
-
With Rails 8, Propshaft is the default asset pipeline for new applications. With Rails 7, you can start a new application with propshaft using `rails new myapp -a propshaft`. For existing applications, check the [upgrade guide](https://github.com/rails/propshaft/blob/main/UPGRADING.md) which contains step-by-step instructions.
|
|
129
|
-
|
|
130
|
-
## Usage
|
|
131
|
-
|
|
132
|
-
Propshaft makes all the assets from all the paths it's been configured with through `config.assets.paths` available for serving and will copy all of them into `public/assets` when precompiling. This is unlike Sprockets, which did not copy over assets that hadn't been explicitly included in one of the bundled assets.
|
|
133
|
-
|
|
134
|
-
You can however exempt directories that have been added through the `config.assets.excluded_paths`. This is useful if you're for example using `app/assets/stylesheets` exclusively as a set of inputs to a compiler like Dart Sass for Rails, and you don't want these input files to be part of the load path. (Remember you need to add full paths, like `Rails.root.join("app/assets/stylesheets")`).
|
|
135
|
-
|
|
136
|
-
These assets can be referenced through their logical path using the normal helpers like `asset_path`, `image_tag`, `javascript_include_tag`, and all the other asset helper tags. These logical references are automatically converted into digest-aware paths in production when `assets:precompile` has been run (through a JSON mapping file found in `public/assets/.manifest.json`).
|
|
137
|
-
|
|
138
|
-
## Referencing digested assets in CSS and JavaScript
|
|
139
|
-
|
|
140
|
-
Propshaft will automatically convert asset references in CSS to use the digested file names. So `background: url("/bg/pattern.svg")` is converted to `background: url("/assets/bg/pattern-2169cbef.svg")` before the stylesheet is served.
|
|
141
|
-
|
|
142
|
-
For JavaScript, you'll have to manually trigger this transformation by using the `RAILS_ASSET_URL` pseudo-method. It's used like this:
|
|
143
|
-
|
|
144
|
-
```javascript
|
|
145
|
-
export default class extends Controller {
|
|
146
|
-
init() {
|
|
147
|
-
this.img = RAILS_ASSET_URL("/icons/trash.svg")
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
That'll turn into:
|
|
153
|
-
|
|
154
|
-
```javascript
|
|
155
|
-
export default class extends Controller {
|
|
156
|
-
init() {
|
|
157
|
-
this.img = "/assets/icons/trash-54g9cbef.svg"
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
## Bypassing the digest step
|
|
163
|
-
|
|
164
|
-
If you need to put multiple files that refer to each other through Propshaft, like a JavaScript file and its source map, you have to digest these files in advance to retain stable file names. Propshaft looks for the specific pattern of `-[digest].digested.js` as the postfix to any asset file as an indication that the file has already been digested.
|
|
165
|
-
|
|
166
|
-
## Subresource Integrity (SRI)
|
|
167
|
-
|
|
168
|
-
Propshaft supports Subresource Integrity (SRI) to help protect against malicious modifications of assets. SRI allows browsers to verify that resources fetched from CDNs or other sources haven't been tampered with by checking cryptographic hashes.
|
|
169
|
-
|
|
170
|
-
### Enabling SRI
|
|
171
|
-
|
|
172
|
-
To enable SRI support, configure the hash algorithm in your Rails application:
|
|
173
|
-
|
|
174
|
-
```ruby
|
|
175
|
-
config.assets.integrity_hash_algorithm = "sha384"
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
Valid hash algorithms include:
|
|
179
|
-
- `"sha256"` - SHA-256 (most common)
|
|
180
|
-
- `"sha384"` - SHA-384 (recommended for enhanced security)
|
|
181
|
-
- `"sha512"` - SHA-512 (strongest)
|
|
182
|
-
|
|
183
|
-
### Using SRI in your views
|
|
184
|
-
|
|
185
|
-
Once configured, you can enable SRI by passing the `integrity: true` option to asset helpers:
|
|
186
|
-
|
|
187
|
-
```erb
|
|
188
|
-
<%= stylesheet_link_tag "application", integrity: true %>
|
|
189
|
-
<%= javascript_include_tag "application", integrity: true %>
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
This generates HTML with integrity hashes:
|
|
193
|
-
|
|
194
|
-
```html
|
|
195
|
-
<link rel="stylesheet" href="/assets/application-abc123.css"
|
|
196
|
-
integrity="sha384-xyz789...">
|
|
197
|
-
<script src="/assets/application-def456.js"
|
|
198
|
-
integrity="sha384-uvw012..."></script>
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
**Important**: SRI only works in secure contexts (HTTPS) or during local development. The integrity hashes are automatically omitted when serving over HTTP in production for security reasons.
|
|
202
|
-
|
|
203
|
-
### Bulk stylesheet inclusion with SRI
|
|
204
|
-
|
|
205
|
-
Propshaft extends `stylesheet_link_tag` with special symbols for bulk inclusion:
|
|
206
|
-
|
|
207
|
-
```erb
|
|
208
|
-
<%= stylesheet_link_tag :all, integrity: true %> <!-- All stylesheets -->
|
|
209
|
-
<%= stylesheet_link_tag :app, integrity: true %> <!-- Only app/assets stylesheets -->
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
## Improving performance in development
|
|
213
|
-
|
|
214
|
-
Before every request Propshaft checks if any asset was updated to decide if a cache sweep is needed. This verification is done using the application's configured file watcher which, by default, is `ActiveSupport::FileUpdateChecker`.
|
|
215
|
-
|
|
216
|
-
If you have a lot of assets in your project, you can improve performance by adding the `listen` gem to the development group in your Gemfile, and this line to the `development.rb` environment file:
|
|
217
|
-
|
|
218
|
-
```ruby
|
|
219
|
-
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
## Migrating from Sprockets
|
|
224
|
-
|
|
225
|
-
Propshaft does a lot less than Sprockets, by design, so it might well be a fair bit of work to migrate if it's even desirable. This is particularly true if you rely on Sprockets to provide any form of transpiling, like CoffeeScript or Sass, or if you rely on any gems that do. You'll need to either stop transpiling or use a Node-based transpiler, like those in [`jsbundling-rails`](https://github.com/rails/jsbundling-rails) and [`cssbundling-rails`](https://github.com/rails/cssbundling-rails).
|
|
226
|
-
|
|
227
|
-
On the other hand, if you're already bundling JavaScript and CSS through a Node-based setup, then Propshaft is going to slot in easily. Since you don't need another tool to bundle or transpile. Just to digest and serve.
|
|
228
|
-
|
|
229
|
-
But for greenfield apps using the default import-map approach, Propshaft can also work well, if you're able to deal with vanilla CSS.
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
## License
|
|
233
|
-
|
|
234
|
-
Propshaft is released under the [MIT License](https://opensource.org/licenses/MIT).
|
|
235
|
-
|
|
236
|
-
## Compilation and Digesting
|
|
237
|
-
|
|
238
|
-
### Asset Processing Pipeline
|
|
239
|
-
|
|
240
|
-
1. **Discovery**: `LoadPath` finds all assets matching patterns
|
|
241
|
-
2. **Compilation**: Each asset processed through registered compilers
|
|
242
|
-
3. **Digesting**: Content hash generated using SHA1 + version string
|
|
243
|
-
4. **Output**: Files written to `config.assets.output_path` (default: `public/assets/`)
|
|
244
|
-
|
|
245
|
-
### Built-in Compilers
|
|
246
|
-
|
|
247
|
-
#### CSS Asset URL Compiler
|
|
248
|
-
Transforms relative URLs to digested versions:
|
|
249
|
-
|
|
250
|
-
```css
|
|
251
|
-
/* Input */
|
|
252
|
-
background: url('./hero.jpg');
|
|
253
|
-
|
|
254
|
-
/* Output */
|
|
255
|
-
background: url('/assets/hero-abc123.jpg');
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
#### JavaScript Asset URL Compiler
|
|
259
|
-
Processes `RAILS_ASSET_URL()` pseudo-functions:
|
|
260
|
-
|
|
261
|
-
```javascript
|
|
262
|
-
// Input
|
|
263
|
-
const icon = RAILS_ASSET_URL('./icon.svg');
|
|
264
|
-
|
|
265
|
-
// Output
|
|
266
|
-
const icon = '/assets/icon-def456.svg';
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
#### Source Map Compiler
|
|
270
|
-
Updates source map references to match digested filenames.
|
|
271
|
-
|
|
272
|
-
### Manifest Generation
|
|
273
|
-
|
|
274
|
-
The manifest file (`.manifest.json`) maps logical paths to digested paths:
|
|
275
|
-
|
|
276
|
-
```json
|
|
277
|
-
{
|
|
278
|
-
"application.js": {
|
|
279
|
-
"digested_path": "application-abc123.js",
|
|
280
|
-
"integrity": "sha384-xyz789..."
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
## Asset Organization
|
|
286
|
-
|
|
287
|
-
```
|
|
288
|
-
app/assets/
|
|
289
|
-
├── builds/ # jsbundling-rails/cssbundling-rails output
|
|
290
|
-
│ ├── application.js
|
|
291
|
-
│ └── application.css
|
|
292
|
-
├── images/ # Static assets
|
|
293
|
-
│ └── logo.svg
|
|
294
|
-
├── stylesheets/ # SCSS source (often excluded)
|
|
295
|
-
│ └── application.scss
|
|
296
|
-
└── javascripts/ # JS source (often excluded)
|
|
297
|
-
└── application.js
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
## Error Handling
|
|
301
|
-
|
|
302
|
-
### Missing Asset Handling
|
|
303
|
-
```ruby
|
|
304
|
-
# Propshaft raises MissingAssetError for missing assets
|
|
305
|
-
begin
|
|
306
|
-
asset_path('nonexistent.js')
|
|
307
|
-
rescue Propshaft::MissingAssetError => e
|
|
308
|
-
Rails.logger.error "Missing asset: #{e.message}"
|
|
309
|
-
# Fallback logic
|
|
310
|
-
end
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
### Development Debugging
|
|
314
|
-
```ruby
|
|
315
|
-
# Show all available assets
|
|
316
|
-
rake assets:reveal
|
|
317
|
-
|
|
318
|
-
# Show asset full paths
|
|
319
|
-
rake assets:reveal:full
|
|
320
|
-
```
|