|
1 | 1 | require "webpacker/configuration"
|
2 | 2 |
|
3 |
| -say "Copying angular loader to config/webpack/loaders" |
4 |
| -copy_file "#{__dir__}/loaders/typescript.js", Rails.root.join("config/webpack/loaders/typescript.js").to_s |
5 |
| - |
6 |
| -say "Adding typescript loader to config/webpack/environment.js" |
7 |
| -insert_into_file Rails.root.join("config/webpack/environment.js").to_s, |
8 |
| - "const typescript = require('./loaders/typescript')\n", |
9 |
| - after: "require('@rails/webpacker')\n" |
10 |
| - |
11 |
| -insert_into_file Rails.root.join("config/webpack/environment.js").to_s, |
12 |
| - "environment.loaders.append('typescript', typescript)\n", |
13 |
| - before: "module.exports" |
14 |
| - |
15 | 3 | say "Copying angular example entry file to #{Webpacker.config.source_entry_path}"
|
16 | 4 | copy_file "#{__dir__}/examples/angular/hello_angular.js", "#{Webpacker.config.source_entry_path}/hello_angular.js"
|
17 | 5 |
|
18 | 6 | say "Copying hello_angular app to #{Webpacker.config.source_path}"
|
19 | 7 | directory "#{__dir__}/examples/angular/hello_angular", "#{Webpacker.config.source_path}/hello_angular"
|
20 | 8 |
|
21 |
| -say "Copying tsconfig.json to the Rails root directory for typescript" |
22 |
| -copy_file "#{__dir__}/examples/angular/tsconfig.json", "tsconfig.json" |
23 |
| - |
24 | 9 | say "Installing all angular dependencies"
|
25 |
| -run "yarn add typescript ts-loader core-js zone.js rxjs @angular/core @angular/common @angular/compiler @angular/platform-browser @angular/platform-browser-dynamic" |
26 |
| - |
27 |
| -say "Webpacker now supports angular and typescript 🎉", :green |
| 10 | +run "yarn add core-js zone.js rxjs @angular/core @angular/common @angular/compiler @angular/platform-browser @angular/platform-browser-dynamic" |
| 11 | + |
| 12 | +if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR > 1 |
| 13 | + say "You need to enable unsafe-eval rule.", :yellow |
| 14 | + say "This can be done in Rails 5.2+ for development environment in the CSP initializer", :yellow |
| 15 | + say "config/initializers/content_security_policy.rb with a snippet like this:", :yellow |
| 16 | + say "if Rails.env.development?", :yellow |
| 17 | + say " p.script_src :self, :https, :unsafe_eval", :yellow |
| 18 | + say "else", :yellow |
| 19 | + say " p.script_src :self, :https", :yellow |
| 20 | + say "end", :yellow |
| 21 | +end |
| 22 | + |
| 23 | +say "Webpacker now supports angular 🎉", :green |
0 commit comments