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

Fix sass option and nix additional yarn install task #2500

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions lib/tasks/webpacker/compile.rake
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
$stdout.sync = true

def yarn_install_available?
rails_major = Rails::VERSION::MAJOR
rails_minor = Rails::VERSION::MINOR

rails_major > 5 || (rails_major == 5 && rails_minor >= 1)
end

def enhance_assets_precompile
# yarn:install was added in Rails 5.1
deps = yarn_install_available? ? [] : ["webpacker:yarn_install"]
Rake::Task["assets:precompile"].enhance(deps) do
Rake::Task["webpacker:compile"].invoke
end
end

namespace :webpacker do
desc "Compile JavaScript packs using webpack for production with digests"
task compile: ["webpacker:verify_install", :environment] do
Expand All @@ -36,8 +21,8 @@ skip_webpacker_precompile = %w(no false n f).include?(ENV["WEBPACKER_PRECOMPILE"

unless skip_webpacker_precompile
if Rake::Task.task_defined?("assets:precompile")
enhance_assets_precompile
Rake::Task["assets:precompile"].enhance(["webpacker:compile"])
else
Rake::Task.define_task("assets:precompile" => ["webpacker:yarn_install", "webpacker:compile"])
Rake::Task.define_task("assets:precompile" => ["yarn:install", "webpacker:compile"])
end
end
10 changes: 0 additions & 10 deletions lib/tasks/webpacker/yarn_install.rake

This file was deleted.

8 changes: 7 additions & 1 deletion package/rules/module.sass.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
const getStyleRule = require('../utils/get_style_rule')
const { resolved_paths: includePaths } = require('../config')

module.exports = getStyleRule(/\.(scss|sass)$/i, true, [
{
loader: 'sass-loader',
options: { sourceMap: true }
options: {
sourceMap: true,
sassOptions: {
includePaths
}
Comment on lines +9 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh I see. Yeah, lets do that.

I am thinking to try and upgrade master to webpack 5 beta too and see if everything works as intended but in another pr.

}
}
])
7 changes: 6 additions & 1 deletion package/rules/sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ const { resolved_paths: includePaths } = require('../config')
module.exports = getStyleRule(/\.(scss|sass)(\.erb)?$/i, false, [
{
loader: 'sass-loader',
options: { sourceMap: true, includePaths }
options: {
sourceMap: true,
sassOptions: {
includePaths
}
}
}
])