Skip to content

Commit

Permalink
extraction des commandes de copie d’assets du package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
adipasquale committed Nov 19, 2024
1 parent 6ed92a5 commit d1f2e89
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,18 @@
Rails.application.config.assets.configure do |env|
env.export_concurrent = false
end

if Rake::Task.task_defined?("assets:precompile") # la tâche n’est définie que dans le contexte de précompilation
Rake::Task["assets:precompile"].enhance do
# copy favicon
FileUtils.cp_r Rails.root.join("app/assets/images/favicon/favicon.ico"), Rails.public_path.join("favicon.ico")
Rails.logger.info "✅ favicon.ico copied"

# DSFR fonts and icons are copied to the root public folder whereas artwork is copied to a public/dsfr/ dir
FileUtils.cp_r Rails.root.join("node_modules/@gouvfr/dsfr/dist/fonts"), Rails.public_path
FileUtils.cp_r Rails.root.join("node_modules/@gouvfr/dsfr/dist/icons"), Rails.public_path
Rails.public_path.join("dsfr").mkdir
FileUtils.cp_r Rails.root.join("node_modules/@gouvfr/dsfr/dist/artwork"), Rails.public_path.join("dsfr/artwork")
Rails.logger.info "✅ DSFR assets copied"
end
end
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "lapin",
"private": true,
"scripts": {
"build": "cp -r node_modules/@gouvfr/dsfr/dist/fonts public; cp -r node_modules/@gouvfr/dsfr/dist/icons public; cp app/assets/images/favicon/favicon.ico public/favicon.ico; mkdir -p public/dsfr; cp -r node_modules/@gouvfr/dsfr/dist/artwork public/dsfr/artwork; webpack --config webpack.config.js"
"build": "webpack --config webpack.config.js"
},
"dependencies": {
"@fortawesome/fontawesome-free": "^6.1.1",
Expand Down

0 comments on commit d1f2e89

Please sign in to comment.