Skip to content

Commit

Permalink
feat(frontend): add tailwindcss 2 compatibility build for webpack 4
Browse files Browse the repository at this point in the history
  • Loading branch information
iaacosta committed May 15, 2021
1 parent e270d22 commit b725173
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Features:

Fixes:
- Explicitly install project specified node version in CircleCI build [#352](https://github.com/platanus/potassium/pull/352)
- Fixes `tailwindCSS@^2` incompatibility with `postcss@^7` [#356](https://github.com/platanus/potassium/pull/356)

## 6.2.0

Expand Down
7 changes: 6 additions & 1 deletion lib/potassium/recipes/front_end.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def add_responsive_meta_tag
end

def setup_tailwind
run 'bin/yarn add tailwindcss'
run "bin/yarn add tailwindcss@#{Potassium::TAILWINDCSS}"
specify_autoprefixer_postcss_compatibility_versions
setup_client_css
remove_server_css_requires
setup_tailwind_requirements
Expand Down Expand Up @@ -147,6 +148,10 @@ def apollo_loading
JS
end

def specify_autoprefixer_postcss_compatibility_versions
run 'bin/yarn add postcss@^7 autoprefixer@^9'
end

def setup_client_css
application_css = 'app/javascript/css/application.css'
create_file application_css, "", force: true
Expand Down
1 change: 1 addition & 0 deletions lib/potassium/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ module Potassium
POSTGRES_VERSION = "11.3"
MYSQL_VERSION = "5.7"
NODE_VERSION = "12"
TAILWINDCSS = "npm:@tailwindcss/postcss7-compat"
end
14 changes: 14 additions & 0 deletions spec/features/front_end_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
expect(File).not_to exist(application_css_path)
end

def expect_to_have_tailwind_compatibility_build
expect(node_modules_file).to include("\"tailwindcss\": \"npm:@tailwindcss/postcss7-compat\"")
expect(node_modules_file).to include("\"autoprefixer\": \"^9\"")
expect(node_modules_file).to include("\"postcss\": \"^7\"")
end

context "with vue" do
before(:all) do
remove_project_directory
Expand Down Expand Up @@ -55,6 +61,10 @@
expect(tailwind_config_file).to include('module.exports')
end

it 'includes correct packages for tailwind, postcss and autoprefixer compatibility build' do
expect_to_have_tailwind_compatibility_build
end

context "with graphql" do
before(:all) do
remove_project_directory
Expand Down Expand Up @@ -84,5 +94,9 @@
it "creates application_js_file for tailwind without vue" do
expect(application_js_file).to include("import '../css/application.css';")
end

it 'includes correct packages for tailwind, postcss and autoprefixer compatibility build' do
expect_to_have_tailwind_compatibility_build
end
end
end

0 comments on commit b725173

Please sign in to comment.