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.

Storefront: fixed install generator

Damian Legawiec0472b2d30226
diff --git a/storefront/Rakefile b/storefront/Rakefile
index 7cc76207b3..56135337be 100644
--- a/storefront/Rakefile
+++ b/storefront/Rakefile
@@ -11,5 +11,5 @@ task default: :spec
desc "Generates a dummy app for testing"
task :test_app do
ENV['LIB_NAME'] = 'spree/storefront'
- Rake::Task['common:test_app'].invoke
+ Rake::Task['common:test_app'].execute
end
diff --git a/storefront/lib/generators/install/install_generator.rb b/storefront/lib/generators/install/install_generator.rb
deleted file mode 100644
index 52a42bb557..0000000000
--- a/storefront/lib/generators/install/install_generator.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-module Spree
- module Storefront
- module Generators
- class InstallGenerator < Rails::Generators::Base
- desc 'Installs Spree Storefront'
-
- def self.source_paths
- [
- File.expand_path('templates', __dir__),
- File.expand_path('../templates', "../#{__FILE__}"),
- File.expand_path('../templates', "../../#{__FILE__}")
- ]
- end
-
- def install
- end
- end
- end
- end
-end
diff --git a/storefront/lib/generators/spree/storefront/install/install_generator.rb b/storefront/lib/generators/spree/storefront/install/install_generator.rb
new file mode 100644
index 0000000000..20f83353df
--- /dev/null
+++ b/storefront/lib/generators/spree/storefront/install/install_generator.rb
@@ -0,0 +1,30 @@
+require 'rails/generators'
+
+module Spree
+ module Storefront
+ module Generators
+ class InstallGenerator < Rails::Generators::Base
+ desc 'Installs Spree Storefront'
+
+ def self.source_paths
+ [
+ File.expand_path('templates', __dir__),
+ File.expand_path('../templates', "../#{__FILE__}"),
+ File.expand_path('../templates', "../../#{__FILE__}")
+ ]
+ end
+
+ def install
+ template 'application.tailwind.css', 'app/assets/stylesheets/application.tailwind.css'
+ template 'tailwind.config.js', 'config/tailwind.config.js'
+
+ unless File.exist?('Procfile.dev')
+ create_file 'Procfile.dev', "storefront_css: bin/rails tailwindcss:watch\n"
+ else
+ append_to_file 'Procfile.dev', "\nstorefront_css: bin/rails tailwindcss:watch" unless File.read('Procfile.dev').include?('storefront_css:')
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/storefront/app/assets/stylesheets/application.tailwind.css b/storefront/lib/generators/spree/storefront/install/templates/application.tailwind.css
similarity index 100%
rename from storefront/app/assets/stylesheets/application.tailwind.css
rename to storefront/lib/generators/spree/storefront/install/templates/application.tailwind.css
diff --git a/storefront/lib/generators/spree/storefront/install/templates/tailwind.config.js b/storefront/lib/generators/spree/storefront/install/templates/tailwind.config.js
new file mode 100644
index 0000000000..8f50678599
--- /dev/null
+++ b/storefront/lib/generators/spree/storefront/install/templates/tailwind.config.js
@@ -0,0 +1,120 @@
+const defaultTheme = require('tailwindcss/defaultTheme')
+
+module.exports = {
+ content: [
+ 'app/views/spree/**/*.erb',
+ 'app/views/devise/**/*.erb',
+ 'engines/spree/storefront/app/views/**/*.erb'
+ ],
+ plugins: [
+ require('@tailwindcss/typography'),
+ require('@tailwindcss/forms'),
+ require('@tailwindcss/aspect-ratio')
+ ],
+ variants: {
+ scrollbar: ['rounded']
+ },
+ safelist: [
+ 'hidden',
+ 'lg:grid',
+ 'grid',
+ 'text-xs',
+ 'text-sm',
+ 'text-base',
+ 'text-lg',
+ 'text-xl',
+ 'text-2xl',
+ 'text-3xl',
+ 'text-4xl',
+ 'text-left',
+ 'text-right',
+ 'text-center',
+ 'cursor-wait',
+ 'lg:sr-only'
+ ],
+ theme: {
+ extend: {
+ fontFamily: {
+ body: ['var(--font-body)', ...defaultTheme.fontFamily.sans]
+ },
+ screens: {
+ lg: { raw: '(min-width: 1024px) { &:not(.force-mobile-view *) }' }
+ },
+ animation: {
+ fadeIn: 'fadeIn 0.5s ease-in-out'
+ },
+ keyframes: {
+ fadeIn: {
+ '0%': { opacity: 0 },
+ '100%': { opacity: 1 }
+ }
+ },
+ colors: {
+ primary: 'var(--primary)',
+ accent: 'var(--accent)',
+ neutral: 'var(--neutral)',
+ danger: 'var(--danger)',
+ success: 'var(--success)',
+
+ 'accent-100': 'var(--accent-100)',
+ 'neutral-50': 'var(--neutral-50)',
+ 'neutral-100': 'var(--neutral-100)',
+ 'neutral-200': 'var(--neutral-200)',
+ 'neutral-300': 'var(--neutral-300)',
+ 'neutral-400': 'var(--neutral-400)',
+ 'neutral-500': 'var(--neutral-500)',
+ 'neutral-600': 'var(--neutral-600)',
+ 'neutral-700': 'var(--neutral-700)',
+ 'neutral-800': 'var(--neutral-800)',
+ 'neutral-900': 'var(--neutral-900)',
+
+ background: 'var(--background)',
+ 'section-background': 'var(--section-background, var(--background))',
+ text: 'var(--text)',
+
+ button: 'rgba(var(--button-rgb), <alpha-value>)',
+ 'button-text': 'var(--button-text)',
+ 'button-hover': 'var(--button-hover)',
+ 'button-hover-text': 'var(--button-hover-text)',
+
+ 'secondary-button': 'var(--secondary-button)',
+ 'secondary-button-text': 'var(--secondary-button-text)',
+ 'secondary-button-hover': 'var(--secondary-button-hover)',
+ 'secondary-button-hover-text': 'var(--secondary-button-hover-text)',
+
+ 'button-light': 'var(--button-light)',
+ 'button-light-text': 'var(--button-light-text)',
+ 'button-light-hover': 'var(--button-light-hover)',
+ 'button-light-hover-text': 'var(--button-light-hover-text)',
+
+ input: 'var(--input)',
+ 'input-bg': 'var(--input-bg)',
+ 'input-text': 'var(--input-text)',
+ 'input-focus': 'var(--input-focus)',
+ 'input-focus-bg': 'var(--input-focus-bg)',
+ 'input-focus-text': 'var(--input-focus-text)'
+ },
+ letterSpacing: {
+ widest: '0.07rem'
+ },
+ typography: {
+ DEFAULT: {
+ css: {
+ '--tw-prose-body': 'var(--text)',
+ '--tw-prose-headings': 'var(--text)',
+ '--tw-prose-bold': 'var(--text)',
+ '--tw-prose-links': 'var(--text)',
+ '--tw-prose-counters': 'var(--text)',
+ '--tw-prose-bullets': 'var(--text)',
+ '--tw-prose-lead': 'var(--text)',
+ '--tw-prose-hr': 'var(--border-default-color)',
+ '--tw-prose-th-borders': 'var(--border-default-color)',
+ '--tw-prose-td-borders': 'var(--border-default-color)',
+ '--tw-prose-quote-borders': 'var(--border-default-color)',
+ '--tw-prose-quotes': 'var(--text)'
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/storefront/spree_storefront.gemspec b/storefront/spree_storefront.gemspec
index 521aa92c4b..20325c392c 100644
--- a/storefront/spree_storefront.gemspec
+++ b/storefront/spree_storefront.gemspec
@@ -41,5 +41,6 @@ Gem::Specification.new do |s|
s.add_dependency 'sprockets', '>= 4.0'
s.add_dependency 'stimulus-rails'
s.add_dependency 'tailwindcss-rails'
+ s.add_dependency 'tailwindcss-ruby', '~> 3.4.17' # lock at Tailwind v3 for now, https://github.com/rails/tailwindcss-rails?tab=readme-ov-file#choosing-a-specific-version-of-tailwindcss
s.add_dependency 'turbo-rails'
end