condenser-rails 1.2 → 2.0.0.rc2
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/README.md +222 -10
- data/lib/condenser/rails/context.rb +1 -1
- data/lib/condenser/rails/helper.rb +2 -2
- data/lib/condenser/rails/task.rb +2 -3
- data/lib/condenser/rails/version.rb +1 -1
- data/lib/condenser/railtie.rb +52 -13
- metadata +33 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 85d5ac4cb95e71d372827c8eda9c52db58726c6cad9c90813b4ae8a519e21b2b
|
|
4
|
+
data.tar.gz: 6801341c6b6043c0bb19fd222a9ff943a1e2dd398625e6977689385992e61bcb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 42a1e35f891b27d5e651fabe7cb1bf3f4db0952567207c0287c40f27146b42fa6804792d250ce624ba39da8bb218114ee47aa05a997c3215efd6fdea28ed54df
|
|
7
|
+
data.tar.gz: 9388b86b8aa8722374af79cbe685dacfe8f47d817eb3dad79dad172a5e367f651486a4d1751dbcd84a5d8964859562e70cd4cb4a205cbf6f9a09dc1ba11252fa
|
data/README.md
CHANGED
|
@@ -2,15 +2,114 @@
|
|
|
2
2
|
|
|
3
3
|
Provides Condenser integration for the Rails Asset Pipeline.
|
|
4
4
|
|
|
5
|
+
Requires Condenser 2.0, Ruby 3.3 or newer, Rails 8.0 or newer, and Node
|
|
6
|
+
wherever assets are compiled. Upgrading from an earlier version? See
|
|
7
|
+
[Upgrading to Condenser 2](#upgrading-to-condenser-2).
|
|
8
|
+
|
|
5
9
|
## Installation
|
|
6
10
|
|
|
7
11
|
``` ruby
|
|
8
12
|
gem 'condenser-rails'
|
|
13
|
+
gem 'sass-embedded' # Sass and SCSS
|
|
14
|
+
gem 'lightningcss', '>= 1.33.0.2' # the default CSS minifier
|
|
9
15
|
```
|
|
10
16
|
|
|
11
17
|
Or alternatively `require 'condenser/railtie'` in your `config/application.rb`
|
|
12
18
|
if you have Bundler auto-require disabled.
|
|
13
19
|
|
|
20
|
+
Sass and SCSS are compiled with [Sass Embedded](https://github.com/sass-contrib/sass-embedded-host-ruby).
|
|
21
|
+
CSS is minified with [Lightning CSS](https://lightningcss.dev); `lightningcss`
|
|
22
|
+
isn't needed if `config.assets.css_minifier` is `:sass` or `nil`.
|
|
23
|
+
|
|
24
|
+
### JavaScript bundling
|
|
25
|
+
|
|
26
|
+
JavaScript is bundled, and minified, with [Rolldown](https://rolldown.rs) by
|
|
27
|
+
default. Rolldown runs in Node, so Node must be installed wherever assets are
|
|
28
|
+
compiled. The `rolldown` npm package is installed into the npm path
|
|
29
|
+
(`config.assets.npm_path`, `Rails.root` by default) the first time it's needed.
|
|
30
|
+
|
|
31
|
+
To configure Rolldown, replace the default exporter with a configured
|
|
32
|
+
`Condenser::RolldownProcessor` instance. Registering the class, as in earlier
|
|
33
|
+
versions, no longer works. Pass `minify:` yourself, since it defaults to
|
|
34
|
+
`false`. `module_types:` loads imports by file extension, e.g.
|
|
35
|
+
`import logo from 'logo.png'` as a data URL:
|
|
36
|
+
|
|
37
|
+
``` ruby
|
|
38
|
+
config.assets.configure do |app, env|
|
|
39
|
+
env.unregister_exporter('application/javascript', Condenser::RolldownProcessor)
|
|
40
|
+
env.register_exporter('application/javascript', Condenser::RolldownProcessor.new(env.npm_path,
|
|
41
|
+
minify: !Rails.env.local?,
|
|
42
|
+
aliases: { 'jquery' => app.root.join('vendor/assets/javascripts/jquery.js').to_s },
|
|
43
|
+
module_types: { png: :dataurl, ttf: :base64 }
|
|
44
|
+
))
|
|
45
|
+
end
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Rollup is deprecated, and will be removed in Condenser 3.
|
|
49
|
+
To use it instead of Rolldown:
|
|
50
|
+
|
|
51
|
+
``` ruby
|
|
52
|
+
config.assets.configure do |app, env|
|
|
53
|
+
env.unregister_exporter('application/javascript')
|
|
54
|
+
env.register_exporter('application/javascript', Condenser::RollupProcessor.new(env.npm_path))
|
|
55
|
+
end
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Tailwind CSS
|
|
59
|
+
|
|
60
|
+
To compile stylesheets with [Tailwind CSS](https://tailwindcss.com) v4, turn it
|
|
61
|
+
on:
|
|
62
|
+
|
|
63
|
+
``` ruby
|
|
64
|
+
# config/application.rb
|
|
65
|
+
config.assets.tailwind = true
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
``` css
|
|
69
|
+
/* app/assets/stylesheets/application.css */
|
|
70
|
+
@import "tailwindcss";
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Stylesheets that `@import "tailwindcss"` or `@reference` another one are
|
|
74
|
+
compiled by `Condenser::TailwindProcessor`; others are left as they are. Like
|
|
75
|
+
Rolldown, it runs in Node, and `tailwindcss`, `@tailwindcss/node` and
|
|
76
|
+
`@tailwindcss/oxide` are installed into the npm path when the asset
|
|
77
|
+
environment is built, if they aren't there.
|
|
78
|
+
|
|
79
|
+
Tailwind scans `app/` for class names: the views, components, helpers and
|
|
80
|
+
JavaScript. Add other directories with `config.assets.tailwind_sources`,
|
|
81
|
+
relative to `Rails.root` or absolute, such as templates in `lib/` or in a gem
|
|
82
|
+
or engine:
|
|
83
|
+
|
|
84
|
+
``` ruby
|
|
85
|
+
config.assets.tailwind_sources = [
|
|
86
|
+
'lib/components',
|
|
87
|
+
File.join(Gem.loaded_specs['some_engine'].full_gem_path, 'app/views')
|
|
88
|
+
]
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Each has to be an existing directory. `app/` and the `tailwind_sources` are
|
|
92
|
+
watched in development, so editing a template's classes rebuilds the CSS.
|
|
93
|
+
`source(...)`, `source(none)` and `@source` in the stylesheet work as in
|
|
94
|
+
Tailwind; `@source` paths outside `app/` and the `tailwind_sources` need to be
|
|
95
|
+
added to `config.assets.watch` to rebuild a running server's CSS.
|
|
96
|
+
|
|
97
|
+
Tailwind doesn't minify its output itself: the CSS minifier
|
|
98
|
+
(`config.assets.css_minifier`, Lightning CSS by default) minifies the whole
|
|
99
|
+
stylesheet outside development and test.
|
|
100
|
+
|
|
101
|
+
The processor is only added to the default pipeline. With a custom
|
|
102
|
+
`config.assets.pipeline`, register it yourself:
|
|
103
|
+
|
|
104
|
+
``` ruby
|
|
105
|
+
config.assets.pipeline do |env|
|
|
106
|
+
# ...
|
|
107
|
+
env.register_preprocessor 'text/css', Condenser::TailwindProcessor.new(env.npm_path,
|
|
108
|
+
sources: [Rails.root.join('app'), Rails.root.join('lib/components')]
|
|
109
|
+
)
|
|
110
|
+
end
|
|
111
|
+
```
|
|
112
|
+
|
|
14
113
|
## Usage
|
|
15
114
|
|
|
16
115
|
### Rake task
|
|
@@ -54,15 +153,97 @@ on assets being precompiled to `public/assets` in order to link to them.
|
|
|
54
153
|
Initializers expecting `Rails.application.assets` during boot should be accessing
|
|
55
154
|
the environment in a `config.assets.configure` block. See below.
|
|
56
155
|
|
|
156
|
+
**`config.assets.npm_path`**
|
|
157
|
+
|
|
158
|
+
The directory npm packages, such as `rolldown`, are installed into and loaded
|
|
159
|
+
from. Defaults to `Rails.root`.
|
|
160
|
+
|
|
161
|
+
**`config.assets.watch`**
|
|
162
|
+
|
|
163
|
+
Directories, relative to `Rails.root` or absolute, that a running server
|
|
164
|
+
watches for changes to files assets depend on, without adding them to the load
|
|
165
|
+
path. Defaults to `['config']`; missing directories are skipped. A
|
|
166
|
+
`depends_on` path starting with `!` is a file relative to `Rails.root`, and
|
|
167
|
+
only rebuilds a running server's assets when it's under a load path or a
|
|
168
|
+
watched directory:
|
|
169
|
+
|
|
170
|
+
``` js
|
|
171
|
+
// depends_on !config/foo.yml
|
|
172
|
+
const foo = <%= YAML.load_file(Rails.root.join('config/foo.yml')).to_json %>;
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
``` ruby
|
|
176
|
+
config.assets.watch << 'data'
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**`config.assets.tailwind`**
|
|
180
|
+
|
|
181
|
+
Compiles stylesheets that `@import "tailwindcss"` with Tailwind. Defaults to
|
|
182
|
+
`false`. See [Tailwind CSS](#tailwind-css).
|
|
183
|
+
|
|
184
|
+
**`config.assets.tailwind_sources`**
|
|
185
|
+
|
|
186
|
+
More directories for Tailwind to scan for class names, besides `app/`,
|
|
187
|
+
relative to `Rails.root` or absolute. Defaults to `[]`.
|
|
188
|
+
|
|
57
189
|
**`config.assets.js_minifier`**
|
|
58
190
|
|
|
59
|
-
The JS minifier to use to minify javascript sources.
|
|
60
|
-
|
|
191
|
+
The JS minifier to use to minify javascript sources. Valid options are
|
|
192
|
+
`:rolldown` (the default, Rolldown minifies its own output), `:terser`, your own
|
|
193
|
+
minifier (a `Condenser::Processor` instance), and `false` or `nil` to disable
|
|
194
|
+
minification. `:terser` runs in Node, is npm-installed into the npm path when
|
|
195
|
+
first used, and turns Rolldown's minifier off.
|
|
61
196
|
|
|
62
197
|
**`config.assets.css_minifier`**
|
|
63
198
|
|
|
64
|
-
The CSS minifier to use to minify css sources.
|
|
65
|
-
|
|
199
|
+
The CSS minifier to use to minify css sources. Valid options are
|
|
200
|
+
`:lightning_css` (the default, which needs the `lightningcss` gem), `:sass`
|
|
201
|
+
(which needs the `sass-embedded` gem), your own minifier (a `Condenser::Processor`
|
|
202
|
+
instance), and `false` or `nil` to disable minification.
|
|
203
|
+
|
|
204
|
+
Assets are only minified outside the `development` and `test` environments.
|
|
205
|
+
|
|
206
|
+
**`config.assets.sourcemap`**
|
|
207
|
+
|
|
208
|
+
Sets condenser's `sourcemap` setting, whether a source map is written for each
|
|
209
|
+
JavaScript bundle and how it's linked:
|
|
210
|
+
|
|
211
|
+
| Value | Map | `//# sourceMappingURL` comment | `SourceMap` header (development server) |
|
|
212
|
+
|---|---|---|---|
|
|
213
|
+
| `false` (default) | no | no | no |
|
|
214
|
+
| `true` | yes | yes | yes |
|
|
215
|
+
| `:linked` | yes | yes | no |
|
|
216
|
+
| `:headers` | yes | no | yes |
|
|
217
|
+
|
|
218
|
+
It applies in every environment, so set it per environment in
|
|
219
|
+
`config/environments/*.rb`. Development builds aren't minified, so maps there
|
|
220
|
+
are optional.
|
|
221
|
+
|
|
222
|
+
``` ruby
|
|
223
|
+
# config/environments/development.rb
|
|
224
|
+
config.assets.sourcemap = true
|
|
225
|
+
|
|
226
|
+
# config/environments/production.rb
|
|
227
|
+
config.assets.sourcemap = :headers
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
In production, precompiled assets are usually served by nginx or a CDN, not
|
|
231
|
+
condenser's server, so nothing sends the `SourceMap` header. With `:headers`
|
|
232
|
+
the map is on disk next to the bundle, with no link to it unless your web
|
|
233
|
+
server adds the header. That's the setup for error trackers such as Sentry:
|
|
234
|
+
upload the maps yourself (e.g. with `sentry-cli sourcemaps upload`). There's no
|
|
235
|
+
separate hidden mode. Use `true` or `:linked` for browsers and error trackers
|
|
236
|
+
to fetch the map from your server.
|
|
237
|
+
|
|
238
|
+
`rake assets:precompile` writes the map next to the bundle, as
|
|
239
|
+
`application-<etag>.js.map`, and adds it to the manifest's `sourcemap` field;
|
|
240
|
+
`assets:clean` keeps it and `assets:clobber` removes it. The development server
|
|
241
|
+
serves it at the bundle's URL plus `.map`. The map covers Rolldown's minifying
|
|
242
|
+
and a `:terser` `js_minifier`. The setting is part of the asset cache key and
|
|
243
|
+
etag, so changing it rebuilds the bundles.
|
|
244
|
+
|
|
245
|
+
`config.assets.sourcemap` applies to any pipeline, including a custom
|
|
246
|
+
`config.assets.pipeline`, since it's set on the environment.
|
|
66
247
|
|
|
67
248
|
**`config.assets.compressors`**
|
|
68
249
|
|
|
@@ -81,10 +262,9 @@ access to the environment instance and lets you lazily load libraries only neede
|
|
|
81
262
|
for asset compiling.
|
|
82
263
|
|
|
83
264
|
``` ruby
|
|
84
|
-
config.assets.configure do |env|
|
|
85
|
-
|
|
265
|
+
config.assets.configure do |app, env|
|
|
86
266
|
require 'my_processor'
|
|
87
|
-
env.register_preprocessor 'application/javascript', MyProcessor
|
|
267
|
+
env.register_preprocessor 'application/javascript', MyProcessor.new
|
|
88
268
|
end
|
|
89
269
|
```
|
|
90
270
|
|
|
@@ -99,9 +279,41 @@ javascript_include_tag :application, integrity: true
|
|
|
99
279
|
# => "<script src="/assets/application.js" integrity="sha256-TvVUHzSfftWg1rcfL6TIJ0XKEGrgLyEq6lEpcmrG9qs="></script>"
|
|
100
280
|
```
|
|
101
281
|
|
|
102
|
-
|
|
103
|
-
|
|
282
|
+
The hash is added whenever `integrity: true` is passed, over HTTP as well as
|
|
283
|
+
HTTPS.
|
|
284
|
+
|
|
285
|
+
## Upgrading to Condenser 2
|
|
286
|
+
|
|
287
|
+
- Requires Condenser 2.0, Ruby 3.3 or newer, Rails 8.0 or newer, and Node
|
|
288
|
+
wherever assets are compiled.
|
|
289
|
+
- Replace `gem 'sassc'` with `gem 'sass-embedded'`, and add
|
|
290
|
+
`gem 'lightningcss', '>= 1.33.0.2'` unless `config.assets.css_minifier` is
|
|
291
|
+
`:sass` or `nil`.
|
|
292
|
+
- JavaScript is bundled and minified by Rolldown by default. `:uglify` is
|
|
293
|
+
removed; `:terser` still works, and turns Rolldown's minifier off.
|
|
294
|
+
- CSS is minified by Lightning CSS by default.
|
|
295
|
+
- A custom Rolldown exporter must be an instance:
|
|
296
|
+
`Condenser::RolldownProcessor.new(env.npm_path, minify: !Rails.env.local?, …)`.
|
|
297
|
+
- Processors registered in `config.assets.pipeline` or `config.assets.configure`,
|
|
298
|
+
and minifiers set with `config.assets.js_minifier` or `css_minifier`, must be
|
|
299
|
+
instances of a `Condenser::Processor` subclass, e.g.
|
|
300
|
+
`env.register_preprocessor 'application/javascript', Condenser::JSAnalyzer.new`.
|
|
301
|
+
Registering a class raises an `ArgumentError`.
|
|
302
|
+
- A bare `// depends_on` path that matches nothing now raises
|
|
303
|
+
`Condenser::FileNotFound` (globs don't). Files relative to the app root need
|
|
304
|
+
a `!`, e.g. `// depends_on !config/foo.yml`. `config/` is watched by default
|
|
305
|
+
so a running server picks up changes to them.
|
|
306
|
+
- A JavaScript import that can't be resolved now fails the build.
|
|
307
|
+
- JSON files can be imported from JavaScript, e.g. `import data from 'data.json'`.
|
|
308
|
+
- Sass `@use` and `@import` of npm packages pick the package's stylesheet from
|
|
309
|
+
its `exports` (`sass` or `style` condition), `sass` or `style` field.
|
|
310
|
+
- A configured `config.assets.npm_path` is now respected instead of being
|
|
311
|
+
reset to `Rails.root`.
|
|
312
|
+
- Tailwind CSS v4 is built in: set `config.assets.tailwind = true`, and
|
|
313
|
+
`config.assets.tailwind_sources` for templates outside `app/`, instead of
|
|
314
|
+
building Tailwind's CSS separately.
|
|
315
|
+
- Clear `tmp/cache/assets` and `public/assets` after upgrading.
|
|
104
316
|
|
|
105
317
|
## License
|
|
106
318
|
|
|
107
|
-
Condenser Rails is released under the [MIT License](
|
|
319
|
+
Condenser Rails is released under the [MIT License](LICENSE).
|
|
@@ -32,7 +32,7 @@ module Condenser::Rails
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def self.extended(obj)
|
|
35
|
-
obj.class_eval do
|
|
35
|
+
obj.singleton_class.class_eval do
|
|
36
36
|
attr_accessor(*VIEW_ACCESSORS)
|
|
37
37
|
end
|
|
38
38
|
end
|
|
@@ -97,7 +97,7 @@ module Condenser::Rails
|
|
|
97
97
|
else
|
|
98
98
|
options["type"]
|
|
99
99
|
end
|
|
100
|
-
rel =
|
|
100
|
+
rel = type == "module" ? "modulepreload" : "preload"
|
|
101
101
|
|
|
102
102
|
if use_preload_links_header && !options["defer"] && href.present? && !href.start_with?("data:")
|
|
103
103
|
preload_link = "<#{href}>; rel=#{rel}; as=script"
|
data/lib/condenser/rails/task.rb
CHANGED
|
@@ -17,9 +17,8 @@ module Condenser::Rails
|
|
|
17
17
|
|
|
18
18
|
def environment
|
|
19
19
|
if app
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
app.assets || Condenser::Railtie.build_environment(app)
|
|
20
|
+
# Its own environment, so compiling never starts a file listener
|
|
21
|
+
@app_environment ||= Condenser::Railtie.build_environment(app, listen: false)
|
|
23
22
|
else
|
|
24
23
|
super
|
|
25
24
|
end
|
data/lib/condenser/railtie.rb
CHANGED
|
@@ -43,7 +43,8 @@ module Rails
|
|
|
43
43
|
app.config.assets.path.unshift(*paths["vendor/assets"].existent_directories)
|
|
44
44
|
app.config.assets.path.unshift(*paths["lib/assets"].existent_directories)
|
|
45
45
|
app.config.assets.path.unshift(*paths["app/assets"].existent_directories)
|
|
46
|
-
app
|
|
46
|
+
# Runs after the app's config, so keep an npm_path the app set
|
|
47
|
+
app.config.assets.npm_path ||= app.root
|
|
47
48
|
end
|
|
48
49
|
end
|
|
49
50
|
end
|
|
@@ -72,11 +73,25 @@ class Condenser::Railtie < ::Rails::Railtie
|
|
|
72
73
|
config.assets.digest = true
|
|
73
74
|
config.assets.cache_limit = 1_000.megabytes
|
|
74
75
|
config.assets.compressors = [:zlib]
|
|
76
|
+
# Used outside development and test; set to nil or false to disable
|
|
77
|
+
config.assets.js_minifier = :rolldown
|
|
78
|
+
config.assets.css_minifier = :lightning_css
|
|
79
|
+
# Source maps: false, true, :linked or :headers, in every environment
|
|
80
|
+
config.assets.sourcemap = false
|
|
81
|
+
# Directories, relative to Rails.root or absolute, whose files can be
|
|
82
|
+
# `depends_on`'d and rebuild assets when they change
|
|
83
|
+
config.assets.watch = ['config']
|
|
84
|
+
# Compile stylesheets that `@import "tailwindcss"` with Tailwind, scanning
|
|
85
|
+
# app/ and the tailwind_sources, relative to Rails.root or absolute
|
|
86
|
+
config.assets.tailwind = false
|
|
87
|
+
config.assets.tailwind_sources = []
|
|
75
88
|
|
|
76
89
|
config.assets.configure do |app, env|
|
|
77
90
|
config.assets.path.each { |path| env.append_path(path) }
|
|
78
|
-
|
|
79
|
-
|
|
91
|
+
# A no-op unless condenser is listening for changes
|
|
92
|
+
Array(config.assets.watch).each do |path|
|
|
93
|
+
path = File.expand_path(path, app.root)
|
|
94
|
+
env.watch(path) if File.directory?(path)
|
|
80
95
|
end
|
|
81
96
|
end
|
|
82
97
|
|
|
@@ -99,9 +114,16 @@ class Condenser::Railtie < ::Rails::Railtie
|
|
|
99
114
|
Condenser::Rails::Task.new(app)
|
|
100
115
|
end
|
|
101
116
|
|
|
102
|
-
|
|
117
|
+
# Minifier names that don't camelize to their class name
|
|
118
|
+
MINIFIERS = {
|
|
119
|
+
lightning_css: 'Condenser::LightningCSSMinifier'
|
|
120
|
+
}.freeze
|
|
121
|
+
|
|
122
|
+
def resolve_minifier(value, env)
|
|
103
123
|
if value.is_a?(Symbol) || value.is_a?(String)
|
|
104
|
-
"Condenser::#{value.to_s.camelize}Minifier".constantize
|
|
124
|
+
klass = (MINIFIERS[value.to_sym] || "Condenser::#{value.to_s.camelize}Minifier").constantize
|
|
125
|
+
# Node minifiers (e.g. Terser) install their package into the npm path
|
|
126
|
+
klass <= Condenser::NodeProcessor ? klass.new(env.npm_path) : klass.new
|
|
105
127
|
else
|
|
106
128
|
value
|
|
107
129
|
end
|
|
@@ -115,25 +137,42 @@ class Condenser::Railtie < ::Rails::Railtie
|
|
|
115
137
|
end
|
|
116
138
|
end
|
|
117
139
|
|
|
118
|
-
|
|
140
|
+
# listen - Whether condenser watches the asset paths for changes. Default
|
|
141
|
+
# only in development and test.
|
|
142
|
+
def build_environment(app, initialized = nil, listen: ::Rails.env.local?)
|
|
119
143
|
initialized = app.initialized? if initialized.nil?
|
|
120
144
|
unless initialized
|
|
121
145
|
::Rails.logger.warn "Application uninitialized: Try calling YourApp::Application.initialize!"
|
|
122
146
|
end
|
|
123
147
|
|
|
124
|
-
env = Condenser.new(pipeline: false, logger: ::Rails.logger, base: app.root.to_s)
|
|
125
148
|
config = app.config
|
|
126
149
|
|
|
150
|
+
# Set the npm path up front so exporters and custom pipelines can use it
|
|
151
|
+
npm_path = config.assets.npm_path if config.assets.npm_path && File.directory?(config.assets.npm_path)
|
|
152
|
+
env = Condenser.new(pipeline: false, logger: ::Rails.logger, base: app.root.to_s, npm_path: npm_path, listen: listen, sourcemap: config.assets.sourcemap || false)
|
|
153
|
+
|
|
127
154
|
if config.assets._pipeline
|
|
128
155
|
config.assets._pipeline.call(env)
|
|
129
156
|
else
|
|
157
|
+
# Only minify outside development and test
|
|
158
|
+
minify = !::Rails.env.local?
|
|
159
|
+
js_minifier = config.assets.js_minifier
|
|
160
|
+
# Rolldown minifies its own output unless another JS minifier is chosen
|
|
161
|
+
rolldown_minifies = minify && js_minifier.to_s == 'rolldown'
|
|
162
|
+
|
|
130
163
|
env.register_transformer 'text/scss', 'text/css', Condenser::ScssTransformer.new
|
|
131
|
-
env.register_preprocessor 'application/javascript', Condenser::JSAnalyzer
|
|
132
|
-
|
|
164
|
+
env.register_preprocessor 'application/javascript', Condenser::JSAnalyzer.new
|
|
165
|
+
if config.assets.tailwind
|
|
166
|
+
# The CSS minifier minifies Tailwind's output with the rest of the
|
|
167
|
+
# stylesheet, so Tailwind doesn't. The processor watches the sources.
|
|
168
|
+
sources = ['app', *config.assets.tailwind_sources].map { |path| File.expand_path(path, app.root) }
|
|
169
|
+
env.register_preprocessor 'text/css', Condenser::TailwindProcessor.new(env.npm_path, sources: sources, minify: false)
|
|
170
|
+
end
|
|
171
|
+
env.register_exporter 'application/javascript', Condenser::RolldownProcessor.new(env.npm_path, minify: rolldown_minifies)
|
|
133
172
|
|
|
134
|
-
if
|
|
135
|
-
env.register_minifier 'application/javascript', resolve_minifier(
|
|
136
|
-
env.register_minifier 'text/css', resolve_minifier(config.assets.css_minifier) if config.assets.css_minifier
|
|
173
|
+
if minify
|
|
174
|
+
env.register_minifier 'application/javascript', resolve_minifier(js_minifier, env) if js_minifier && !rolldown_minifies
|
|
175
|
+
env.register_minifier 'text/css', resolve_minifier(config.assets.css_minifier, env) if config.assets.css_minifier
|
|
137
176
|
end
|
|
138
177
|
|
|
139
178
|
env.register_writer Condenser::FileWriter.new
|
|
@@ -164,7 +203,7 @@ class Condenser::Railtie < ::Rails::Railtie
|
|
|
164
203
|
app.assets = self.build_environment(app, true)
|
|
165
204
|
require 'condenser/server'
|
|
166
205
|
app.routes.prepend do
|
|
167
|
-
mount Condenser::Server.new(app.assets, logger: Rails.logger)
|
|
206
|
+
mount Condenser::Server.new(app.assets, logger: Rails.logger), at: config.assets.prefix
|
|
168
207
|
end
|
|
169
208
|
end
|
|
170
209
|
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: condenser-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0.rc2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonathan Bracy
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: condenser
|
|
@@ -16,56 +15,62 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
18
|
+
version: 2.0.0.rc2
|
|
19
|
+
- - "<"
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '3'
|
|
20
22
|
type: :runtime
|
|
21
23
|
prerelease: false
|
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
25
|
requirements:
|
|
24
26
|
- - ">="
|
|
25
27
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
28
|
+
version: 2.0.0.rc2
|
|
29
|
+
- - "<"
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '3'
|
|
27
32
|
- !ruby/object:Gem::Dependency
|
|
28
33
|
name: actionpack
|
|
29
34
|
requirement: !ruby/object:Gem::Requirement
|
|
30
35
|
requirements:
|
|
31
36
|
- - ">="
|
|
32
37
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
38
|
+
version: '8.0'
|
|
34
39
|
type: :runtime
|
|
35
40
|
prerelease: false
|
|
36
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
42
|
requirements:
|
|
38
43
|
- - ">="
|
|
39
44
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
45
|
+
version: '8.0'
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
|
42
47
|
name: activesupport
|
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
|
44
49
|
requirements:
|
|
45
50
|
- - ">="
|
|
46
51
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
52
|
+
version: '8.0'
|
|
48
53
|
type: :runtime
|
|
49
54
|
prerelease: false
|
|
50
55
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
56
|
requirements:
|
|
52
57
|
- - ">="
|
|
53
58
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
59
|
+
version: '8.0'
|
|
55
60
|
- !ruby/object:Gem::Dependency
|
|
56
61
|
name: railties
|
|
57
62
|
requirement: !ruby/object:Gem::Requirement
|
|
58
63
|
requirements:
|
|
59
64
|
- - ">="
|
|
60
65
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
66
|
+
version: '8.0'
|
|
62
67
|
type: :development
|
|
63
68
|
prerelease: false
|
|
64
69
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
70
|
requirements:
|
|
66
71
|
- - ">="
|
|
67
72
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
73
|
+
version: '8.0'
|
|
69
74
|
- !ruby/object:Gem::Dependency
|
|
70
75
|
name: rake
|
|
71
76
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -95,7 +100,7 @@ dependencies:
|
|
|
95
100
|
- !ruby/object:Gem::Version
|
|
96
101
|
version: '0'
|
|
97
102
|
- !ruby/object:Gem::Dependency
|
|
98
|
-
name:
|
|
103
|
+
name: sass-embedded
|
|
99
104
|
requirement: !ruby/object:Gem::Requirement
|
|
100
105
|
requirements:
|
|
101
106
|
- - ">="
|
|
@@ -108,6 +113,20 @@ dependencies:
|
|
|
108
113
|
- - ">="
|
|
109
114
|
- !ruby/object:Gem::Version
|
|
110
115
|
version: '0'
|
|
116
|
+
- !ruby/object:Gem::Dependency
|
|
117
|
+
name: lightningcss
|
|
118
|
+
requirement: !ruby/object:Gem::Requirement
|
|
119
|
+
requirements:
|
|
120
|
+
- - ">="
|
|
121
|
+
- !ruby/object:Gem::Version
|
|
122
|
+
version: 1.33.0.2
|
|
123
|
+
type: :development
|
|
124
|
+
prerelease: false
|
|
125
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
126
|
+
requirements:
|
|
127
|
+
- - ">="
|
|
128
|
+
- !ruby/object:Gem::Version
|
|
129
|
+
version: 1.33.0.2
|
|
111
130
|
- !ruby/object:Gem::Dependency
|
|
112
131
|
name: minitest-reporters
|
|
113
132
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -122,7 +141,6 @@ dependencies:
|
|
|
122
141
|
- - ">="
|
|
123
142
|
- !ruby/object:Gem::Version
|
|
124
143
|
version: '0'
|
|
125
|
-
description:
|
|
126
144
|
email: jonbracy@gmail.com
|
|
127
145
|
executables: []
|
|
128
146
|
extensions: []
|
|
@@ -141,7 +159,6 @@ homepage: https://github.com/malomalo/condenser-rails
|
|
|
141
159
|
licenses:
|
|
142
160
|
- MIT
|
|
143
161
|
metadata: {}
|
|
144
|
-
post_install_message:
|
|
145
162
|
rdoc_options: []
|
|
146
163
|
require_paths:
|
|
147
164
|
- lib
|
|
@@ -149,15 +166,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
149
166
|
requirements:
|
|
150
167
|
- - ">="
|
|
151
168
|
- !ruby/object:Gem::Version
|
|
152
|
-
version:
|
|
169
|
+
version: 3.3.0
|
|
153
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
171
|
requirements:
|
|
155
172
|
- - ">="
|
|
156
173
|
- !ruby/object:Gem::Version
|
|
157
174
|
version: '0'
|
|
158
175
|
requirements: []
|
|
159
|
-
rubygems_version:
|
|
160
|
-
signing_key:
|
|
176
|
+
rubygems_version: 4.0.11
|
|
161
177
|
specification_version: 4
|
|
162
178
|
summary: Condenser integration for Rails
|
|
163
179
|
test_files: []
|