Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Support JS Bundling of Spree Dashboard (#11470)

Damian Legawiec7c2f0529a254
diff --git a/bin/sandbox.sh b/bin/sandbox.sh
index ef91e4b52b..cc1e411cbc 100755
--- a/bin/sandbox.sh
+++ b/bin/sandbox.sh
@@ -78,6 +78,8 @@ gem 'sassc', github: 'sass/sassc-ruby', branch: 'master'
gem 'rack-cache'
gem 'oj'
+
+gem 'jsbundling-rails'
RUBY
cat <<RUBY >> config/environments/development.rb
@@ -103,10 +105,15 @@ end
RUBY
bundle install --gemfile Gemfile
-bundle exec rails db:drop || true
-bundle exec rails db:create
-bundle exec rails g spree:install --auto-accept --user_class=Spree::User --sample=true
-bundle exec rails g spree:backend:install
-bundle exec rails g spree:emails:install
-bundle exec rails g spree:auth:install
-bundle exec rails g spree_gateway:install
+
+bin/rails javascript:install:esbuild
+yarn link @spree/dashboard
+yarn install
+
+bin/rails db:drop || true
+bin/rails db:create
+bin/rails g spree:install --auto-accept --user_class=Spree::User --sample=true
+bin/rails g spree:backend:install
+bin/rails g spree:emails:install
+bin/rails g spree:auth:install
+bin/rails g spree_gateway:install
diff --git a/core/lib/spree/testing_support/common_rake.rb b/core/lib/spree/testing_support/common_rake.rb
index 0cb219b7a2..1196a6349c 100644
--- a/core/lib/spree/testing_support/common_rake.rb
+++ b/core/lib/spree/testing_support/common_rake.rb
@@ -14,6 +14,13 @@ namespace :common do
ENV['RAILS_ENV'] = 'test'
Rails.env = 'test'
+ if ENV['LIB_NAME'] == 'spree/backend'
+ puts 'Preparing NPM package...'
+ system('yarn install')
+ system('yarn build')
+ system('yarn link')
+ end
+
Spree::DummyGenerator.start ["--lib_name=#{ENV['LIB_NAME']}", '--quiet']
Spree::InstallGenerator.start [
"--lib_name=#{ENV['LIB_NAME']}",
@@ -42,6 +49,12 @@ namespace :common do
end
unless ['spree/api', 'spree/core', 'spree/sample'].include?(ENV['LIB_NAME'])
+ if ENV['LIB_NAME'] == 'spree/backend'
+ puts 'Installing node dependencies...'
+ system('bin/rails javascript:install:esbuild')
+ system('yarn link @spree/dashboard')
+ system('yarn install')
+ end
puts 'Precompiling assets...'
system('bundle exec rake assets:precompile')
end