I am currently working on an integration of Dart into the Rails Asset Pipeline.
我目前正致力于将Dart集成到Rails Asset Pipeline中。
Compilation is already working; .dart
files are compiled into .js
by the Asset Pipeline. However, there should also be an uncompiled .dart
version that can be interpreted by Dartium.
编译工作已经开始; .dart文件由Asset Pipeline编译成.js。但是,还应该有一个可以由Dartium解释的未编译的.dart版本。
The usual way is that .dart
files are included in the html source with a type of "application/dart"
. Then there's dart.js, which replaces those .dart
files with the corresponding .js
version if the browser doesn't understand Dart, replacding foo.dart
with foo.dart.js
.
通常的方法是.dart文件包含在html源代码中,类型为“application / dart”。然后是dart.js,如果浏览器不理解Dart,用相应的.js版本替换那些.dart文件,用foo.dart.js替换foo.dart。
My problem is, that the asset pipeline is serving the compiled JavaScript version, even if the client requests foo.dart
. foo.dart
should serve the original, uncompiled version, only foo.dart.js
should be compiled.
我的问题是,资产管道服务于已编译的JavaScript版本,即使客户端请求foo.dart。 foo.dart应该提供原始的,未编译的版本,只应编译foo.dart.js。
Source for ruby-dart and dart-rails
ruby-dart和dart-rails的来源
Edit: I thought about just copying the raw .dart
files to the public folder, but that's not an option, since the source file that is seen by the Asset Pipeline might include other .dart
files, which are then compiled into one single .js
file. So, not all .dart
files would be copied.
编辑:我想过只是将原始.dart文件复制到公共文件夹,但这不是一个选项,因为Asset Pipeline看到的源文件可能包含其他.dart文件,然后将这些文件编译成一个.js文件文件。因此,并非所有.dart文件都会被复制。
2 个解决方案
#1
1
you can put your .dart files directly in public/assets/
你可以把你的.dart文件直接放在public / assets /
You should only put assets you want to pre-process into app/assets/ (or vendor/assets/... etc.). The assets that you don't want pre-processed, can be put directly in public/assets/ folder
您只应将要预处理的资产放入app / assets /(或vendor / assets / ...等)。您不希望预处理的资产可以直接放在public / assets /文件夹中
#2
-1
I wonder if it might be easier to skip the asset pipeline altogether and rely on Dart editor to compile your JavaScript whenever you're happy with your code. Sorry, I know that's a bit ghetto.
我想知道是否可以更容易地跳过资产管道并依赖Dart编辑器在您对代码感到满意时编译JavaScript。对不起,我知道这有点贫民窟。
#1
1
you can put your .dart files directly in public/assets/
你可以把你的.dart文件直接放在public / assets /
You should only put assets you want to pre-process into app/assets/ (or vendor/assets/... etc.). The assets that you don't want pre-processed, can be put directly in public/assets/ folder
您只应将要预处理的资产放入app / assets /(或vendor / assets / ...等)。您不希望预处理的资产可以直接放在public / assets /文件夹中
#2
-1
I wonder if it might be easier to skip the asset pipeline altogether and rely on Dart editor to compile your JavaScript whenever you're happy with your code. Sorry, I know that's a bit ghetto.
我想知道是否可以更容易地跳过资产管道并依赖Dart编辑器在您对代码感到满意时编译JavaScript。对不起,我知道这有点贫民窟。