Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tiny MCE Alchemy Skin css doesn't not get compiled in production #3059

Closed
ck2000 opened this issue Sep 30, 2024 · 4 comments · Fixed by #3062
Closed

Tiny MCE Alchemy Skin css doesn't not get compiled in production #3059

ck2000 opened this issue Sep 30, 2024 · 4 comments · Fixed by #3062

Comments

@ck2000
Copy link

ck2000 commented Sep 30, 2024

Steps to reproduce

I am using rails 7.2 and alchemy_cms (7.3.0). In production the I am getting a 404 not found failed to load resource: the server responded with a status of 404 () mydomain.com/assets/tinymce/skins/ui/alchemy/content.min.css and my domain.com/assets/tinymce/skins/ui/alchemy/skin.min.css

On my server the current/public/assets/tinymce directory does not include a skins directory...

The TinyMCE editor does not work...

my environments/production.rb

require "active_support/core_ext/integer/time"

Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # Code is not reloaded between requests.
  config.enable_reloading = false

  # Eager load code on boot. This eager loads most of Rails and
  # your application in memory, allowing both threaded web servers
  # and those relying on copy on write to perform better.
  # Rake tasks automatically ignore this option for performance.
  config.eager_load = true

  # Full error reports are disabled and caching is turned on.
  config.consider_all_requests_local = false
  config.action_controller.perform_caching = true

  # Do not fall back to assets pipeline if a precompiled asset is missed.
  config.assets.compile = false

  # Store uploaded files on the local file system (see config/storage.yml for options).
  config.active_storage.service = :amazon

  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
  config.force_ssl = true

  # Log to STDOUT by default
  config.logger = ActiveSupport::Logger.new(STDOUT)
    .tap  { |logger| logger.formatter = ::Logger::Formatter.new }
    .then { |logger| ActiveSupport::TaggedLogging.new(logger) }

  # Prepend all log lines with the following tags.
  config.log_tags = [ :request_id ]

  # "info" includes generic and useful information about system operation, but avoids logging too much
  # information to avoid inadvertent exposure of personally identifiable information (PII). If you
  # want to log everything, set the level to "debug".
  config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")

  # Disable caching for Action Mailer templates even if Action Controller
  # caching is enabled.
  config.action_mailer.perform_caching = false

  # Ignore bad email addresses and do not raise email delivery errors.
  # Set this to true and configure the email server for immediate delivery to raise delivery errors.
  # config.action_mailer.raise_delivery_errors = false

  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  # the I18n.default_locale when a translation cannot be found).
  config.i18n.fallbacks = true

  # Don't log any deprecations.
  config.active_support.report_deprecations = false

  # Do not dump schema after migrations.
  config.active_record.dump_schema_after_migration = false
end

Expected behavior

TinyMCE does load as it is doing in development.

Actual behavior

Tell us what happens instead

System configuration

  • Alchemy Version: 7.3.0
  • Rails Version: 7.2
@tvdeyen
Copy link
Member

tvdeyen commented Oct 3, 2024

The skin does not need to be compiled anymore. Alchemy now includes a compiled css file that gets served by Sprockets.

The file that is configured in the default config is at /assets/tinymce/skins/content/alchemy/content.min.css. It seems it tries to load /assets/tinymce/skins/ui/alchemy/content.min.css, which is not correct.

Do you have a custom Tinymce config?

@ck2000
Copy link
Author

ck2000 commented Oct 3, 2024

Thank you for your response. I am using Alchemy out of the box.

I have created a monkey patch / rake task which solves the issue temporarily:

namespace :assets do
desc 'Copy tinymce content.min.css without digest'
task copy_tinymce_css: :environment do
source_content = Rails.root.join('app/assets/stylesheets/tinymce/skins/ui/alchemy/content.min.css')
source_skin = Rails.root.join('app/assets/stylesheets/tinymce/skins/ui/alchemy/skin.min.css')
destination_skin = '/home/k1/www/boardclub/current/public/assets/tinymce/skins/ui/alchemy'
destination_content = '/home/k1/www/boardclub/current/public/assets/tinymce/skins/content/alchemy'

# Create the destination directory if it doesn't exist
p "Create the destination directories ... #{destination_skin}"
FileUtils.mkdir_p(destination_skin)
p "Create the destination directories ... #{destination_content}"
FileUtils.mkdir_p(destination_content)

# Copy the file to the public/assets directory without digest
FileUtils.cp(source_content, destination_content +'/content.min.css')
FileUtils.cp(source_skin, destination_skin + '/skin.min.css')

puts "Tinymce skin.min.css and content.min.css copied to #{destination_skin} and #{destination_content}"

end
end

@tvdeyen
Copy link
Member

tvdeyen commented Oct 3, 2024

This is interesting, since we deal with this in https://github.com/AlchemyCMS/alchemy_cms/blob/7.3-stable/lib/non_stupid_digest_assets.rb called here

NonStupidDigestAssets.whitelist += [/^tinymce\//]

@tvdeyen
Copy link
Member

tvdeyen commented Oct 3, 2024

Found the issue. Fix upcoming

@tvdeyen tvdeyen closed this as completed in 157552f Oct 3, 2024
tvdeyen added a commit that referenced this issue Oct 3, 2024
We only tell sprockets to copy the compiled alchemy styles
during precompilation, but we also need the Tinymce skin
files.

Closes #3059

(cherry picked from commit 157552f)
zp1984 added a commit to zp1984/alchemy_cms that referenced this issue Oct 4, 2024
SecureRandom was added to the factory to ensure unique names during tests

fix Validation error

SecureRandom was added to the factory to ensure unique names during tests

test develop

add test for validation on name

fix test

fix lint

running standardrb --fix

fix lint

delete duplicate

Remove unused tinymce skin files

We use the minified versions of these files.

Add tinymce skin files to Sprockets manifest.

We only tell sprockets to copy the compiled alchemy styles
during precompilation, but we also need the Tinymce skin
files.

Closes AlchemyCMS#3059

Update all development npm dependencies (2024-10-03)

Update tinymce package after rollup plugin update

The commonjs plugin was updated and produced a new minified file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants