bridgetown-plugin-tailwindcss 0.1.2 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02adc20df692a49f8c838710481f8f51ae1769e214a957715330c2a46b4a4f0f
4
- data.tar.gz: 70e248fd006a26c49f284c11d43b0700019f34b93ac9de72caa2778d6b45972a
3
+ metadata.gz: 05c15d69195b9dfe1eb8047f2210d15f9fa57cefc846b3c98add0269fbb4b0da
4
+ data.tar.gz: be528c7167c5d0173c3af625e32c55b19df06fc07176bbfc10bfff04699fc1af
5
5
  SHA512:
6
- metadata.gz: 8c9133b819b886276eb8542ebd734fd4dc99f02a51e991ea348be7c51baf02cf95ffdb34ecfca77da7d715aa5f289b6692e6815e3556236603da15b46ce78b2d
7
- data.tar.gz: b32326cad89045140db9a2bd0510ad25f13284f1cd9ed0d46f30c7690777ad990e1e9150da04f202b08c08b9dfff7e70f058ce018292d2033c1c9554be9e8535
6
+ metadata.gz: f537774f6d165f4d10366a378431d581eb1a7acecbcc1c4f973d5d76f554a6ac78175522bd01906e1f728aaa9d002977f8dc8241633af1e03a1832744cf8a2e2
7
+ data.tar.gz: 1fb7440d903d0f52a711ae9ed6c2e3c3744241ef52c051d97a65918099bddba42b64d13face263f874074237b736a5227ace766761d91d2c64191b736c1a297e
data/README.md CHANGED
@@ -52,13 +52,27 @@ where friendly folks are standing by to help you build and release your plugin o
52
52
  **NOTE:** make sure you add the `bridgetown-plugin` [topic](https://github.com/topics/bridgetown-plugin) to your
53
53
  plugin's GitHub repo so the plugin or theme will show up on [Bridgetown's official Plugin Directory](https://www.bridgetownrb.com/plugins)! (There may be a day or so delay before you see it appear.)
54
54
 
55
+ ## Usage
56
+
55
57
 
58
+ ```bash
59
+ bridgetown new mysite
60
+ cd mysite
61
+ bridgetown tailwind_init
62
+ ```
56
63
 
57
- ```javascript
58
- // frontend/styles/index.js
59
- @import 'tailwindcss/base';
60
- @import 'tailwindcss/components';
61
- @import 'tailwindcss/utilities';
64
+ ```ruby
65
+ # Gemfile
62
66
 
63
- // ...
67
+ # ...
68
+ group :bridgetown_plugins do
69
+ gem "bridgetown-plugin-tailwindcss", "~> 0.1.13"
70
+ end
64
71
  ```
72
+
73
+ ## Issues
74
+
75
+ Right now, the script does not do a smart replace of
76
+ `webpack.config.js`. If you have a webpack config different from the
77
+ stock version of Bridgetown it will be replaced with the default
78
+ bridgetown version with a PostCss loader.
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ RSpec::Core::RakeTask.new(:spec)
9
9
  task :default => :spec
10
10
  task :test => :spec
11
11
 
12
- task :release do
12
+ task :deploy do
13
13
  Rake.sh "./script/release"
14
14
  end
15
15
 
@@ -3,102 +3,167 @@
3
3
  require "bridgetown"
4
4
  require_relative "utils"
5
5
 
6
- class TailwindInit < Bridgetown::Command
7
- ACTIONS = TailwindCss::Utils::Actions.new
8
-
9
- class << self
10
- def init_with_program(prog)
11
- prog.command(:tailwind_init) do |c|
12
- c.syntax "tailwind_init"
13
- c.description "Initialize config for Tailwind"
14
- # c.option 'path', '--path', 'Choose the path to install tailwind'
15
-
16
- c.action do |_args, _options|
17
- Bridgetown::Commands::TailwindInit.new.run
6
+ module Bridgetown
7
+ module Commands
8
+ class TailwindInit < Command
9
+ ACTIONS = TailwindCss::Utils::Actions.new
10
+
11
+ class << self
12
+ def init_with_program(prog)
13
+ prog.command(:tailwind_init) do |c|
14
+ c.syntax "tailwind_init"
15
+ c.description "Initialize config for Tailwind"
16
+ # c.option 'path', '--path', 'Choose the path to install tailwind'
17
+
18
+ c.action do |_args, _options|
19
+ run
20
+ end
21
+ end
18
22
  end
19
- end
20
- end
21
23
 
22
- private
24
+ private
23
25
 
24
- def run
25
- write_files
26
- end
26
+ def run
27
+ write_files
28
+ end
27
29
 
28
- def write_files
29
- webpack_config = File.expand_path("webpack.config.js")
30
- tailwind_config = File.expand_path("tailwind.config.js")
30
+ def write_files
31
+ webpack_config = File.expand_path("webpack.config.js")
32
+ tailwind_config = File.expand_path("tailwind.config.js")
31
33
 
32
- ACTIONS.create_file(webpack_config, webpack_file_contents)
33
- ACTIONS.create_file(tailwind_config, tailwind_config_contents)
34
- prepend_to_stylesheet
35
- end
34
+ ACTIONS.create_file(webpack_config, webpack_file_contents)
35
+ ACTIONS.create_file(tailwind_config, tailwind_config_contents)
36
+ prepend_to_stylesheet
37
+ end
36
38
 
37
- def prepend_to_stylesheet
38
- frontend_stylesheet = File.join("frontend", "styles", "index.scss")
39
- frontend_stylesheet = File.expand_path(frontend_stylesheet)
39
+ def prepend_to_stylesheet
40
+ frontend_stylesheet = File.join("frontend", "styles", "index.scss")
41
+ frontend_stylesheet = File.expand_path(frontend_stylesheet)
40
42
 
41
- return unless File.exist?(frontend_stylesheet)
43
+ return unless File.exist?(frontend_stylesheet)
42
44
 
43
- ACTIONS.prepend_to_file(frontend_stylesheet, import_tailwind_contents)
44
- end
45
+ ACTIONS.prepend_to_file(frontend_stylesheet, import_tailwind_contents)
46
+ end
45
47
 
46
- def import_tailwind_contents
47
- <<~IMPORT
48
- @import 'tailwindcss/base';
49
- @import 'tailwindcss/components';
50
- @import 'tailwindcss/utilities';
51
- IMPORT
52
- end
48
+ def import_tailwind_contents
49
+ <<~IMPORT
50
+ @import 'tailwindcss/base';
51
+ @import 'tailwindcss/components';
52
+ @import 'tailwindcss/utilities';
53
53
 
54
- def tailwind_config_contents
55
- <<~TAILWIND
56
- module.exports = {
57
- purge: {
58
- enabled: true,
59
- content: ['./src/**/*.html'],
60
- },
61
- theme: {
62
- extend: {},
63
- },
64
- variants: {},
65
- plugins: [],
66
- }
67
- TAILWIND
68
- end
54
+ IMPORT
55
+ end
69
56
 
70
- def webpack_file_contents
71
- <<~WEBPACK
72
- {
73
- test: /\.(s[ac]|c)ss$/,
74
- use: [
75
- MiniCssExtractPlugin.loader,
76
- "css-loader",
77
- {
78
- loader: "sass-loader",
79
- options: {
80
- sassOptions: {
81
- includePaths: [
82
- path.resolve(__dirname, "src/_components"),
83
- path.resolve(__dirname, "src/_includes"),
84
- ],
85
- },
57
+ def tailwind_config_contents
58
+ <<~TAILWIND
59
+ module.exports = {
60
+ purge: {
61
+ mode: 'production',
62
+ content: ['./src/**/*.html'],
63
+ },
64
+ theme: {
65
+ extend: {},
86
66
  },
87
- },
88
- {
89
- loader: "postcss-loader",
90
- options: {
91
- ident: "postcss",
92
- plugins: [
93
- require("postcss-import"),
94
- require("tailwindcss"),
95
- require("autoprefixer"),
67
+ variants: {},
68
+ plugins: [],
69
+ }
70
+ TAILWIND
71
+ end
72
+
73
+ def webpack_file_contents
74
+ <<~WEBPACK
75
+ const path = require("path");
76
+ const MiniCssExtractPlugin = require("mini-css-extract-plugin");
77
+ const ManifestPlugin = require("webpack-manifest-plugin");
78
+
79
+ module.exports = {
80
+ entry: "./frontend/javascript/index.js",
81
+ devtool: "source-map",
82
+ // Set some or all of these to true if you want more verbose logging:
83
+ stats: {
84
+ modules: false,
85
+ builtAt: false,
86
+ timings: false,
87
+ children: false,
88
+ },
89
+ output: {
90
+ path: path.resolve(__dirname, "output", "_bridgetown", "static", "js"),
91
+ filename: "all.[contenthash].js",
92
+ },
93
+ resolve: {
94
+ extensions: [".js", ".jsx"],
95
+ },
96
+ plugins: [
97
+ new MiniCssExtractPlugin({
98
+ filename: "../css/all.[contenthash].css",
99
+ }),
100
+ new ManifestPlugin({
101
+ fileName: path.resolve(__dirname, ".bridgetown-webpack", "manifest.json"),
102
+ }),
103
+ ],
104
+ module: {
105
+ rules: [
106
+ {
107
+ test: /.(js|jsx)/,
108
+ use: {
109
+ loader: "babel-loader",
110
+ options: {
111
+ presets: ["@babel/preset-env"],
112
+ plugins: [
113
+ "@babel/plugin-proposal-class-properties",
114
+ [
115
+ "@babel/plugin-transform-runtime",
116
+ {
117
+ helpers: false,
118
+ },
119
+ ],
120
+ ],
121
+ },
122
+ },
123
+ },
124
+ {
125
+ test: /.(s[ac]|c)ss$/,
126
+ use: [
127
+ MiniCssExtractPlugin.loader,
128
+ "css-loader",
129
+ {
130
+ loader: "sass-loader",
131
+ options: {
132
+ sassOptions: {
133
+ includePaths: [
134
+ path.resolve(__dirname, "src/_components"),
135
+ path.resolve(__dirname, "src/_includes"),
136
+ ],
137
+ },
138
+ },
139
+ },
140
+ {
141
+ loader: "postcss-loader",
142
+ options: {
143
+ ident: "postcss",
144
+ plugins: [
145
+ require("postcss-import"),
146
+ require("tailwindcss"),
147
+ require("autoprefixer"),
148
+ ],
149
+ },
150
+ },
151
+ ],
152
+ },
153
+ {
154
+ test: /.woff2?$|.ttf$|.eot$|.svg$/,
155
+ loader: "file-loader",
156
+ options: {
157
+ outputPath: "../fonts",
158
+ publicPath: "../fonts",
159
+ },
160
+ },
96
161
  ],
97
162
  },
98
- },
99
- ],
100
- },
101
- WEBPACK
163
+ };
164
+ WEBPACK
165
+ end
166
+ end
102
167
  end
103
168
  end
104
169
  end
@@ -12,7 +12,11 @@ module TailwindCss
12
12
  class Bump < Thor
13
13
  include Thor::Actions
14
14
 
15
+ RUBY_VERSION_REGEX = %r!(.*VERSION.?=.*)!.freeze
16
+ NPM_VERSION_REGEX = %r!(.*"version":.*)!.freeze
17
+ VERSION_LINE = Regexp.union(RUBY_VERSION_REGEX, NPM_VERSION_REGEX)
15
18
  VERSION_REGEX = %r!(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)!.freeze
19
+ GSUB_REGEX = %r!(?<version>#{VERSION_LINE})#{VERSION_REGEX}!.freeze
16
20
 
17
21
  # rubocop:disable Metrics/BlockLength
18
22
  no_commands do
@@ -23,30 +27,43 @@ module TailwindCss
23
27
  def bump_version_to_string(string)
24
28
  say("Bumping from #{VERSION} to #{string}", :red)
25
29
 
30
+ match = GSUB_REGEX.match(File.read(file))
31
+ gsub_string = "#{match[:version]}#{string}"
26
32
  version_files.each do |file|
27
- gsub_file(file, VERSION_REGEX, string)
33
+ gsub_file(file, GSUB_REGEX, gsub_string)
28
34
  end
29
35
  end
30
36
 
31
- def bump_version(type, version: VERSION, value: nil)
32
- say(version_change(type, version: version, value: value), :red)
37
+ def bump_version(type, version: VERSION)
38
+ say(version_change(type, version: version), :red)
33
39
 
34
40
  version_files.each do |file|
35
- gsub_file(file, VERSION_REGEX,
36
- to_version(type, version: version, value: value))
41
+ match = GSUB_REGEX.match(File.read(file))
42
+ gsub_string = "#{match[:version]}#{to_version(type, version: version)}"
43
+
44
+ gsub_file(file, GSUB_REGEX,
45
+ gsub_string)
37
46
  end
38
47
  end
39
48
 
40
49
  private
41
50
 
51
+ def gsub_match(file)
52
+ GSUB_REGEX.match(File.read(file))
53
+ end
54
+
42
55
  def version_files
43
- @package_json = File.expand_path("package.json")
44
- @version_file = File.expand_path(File.join(__dir__, "version.rb"))
56
+ package_json = File.expand_path("package.json")
57
+ version_file = File.expand_path(File.join(__dir__, "version.rb"))
45
58
 
46
- [@package_json, @version_file]
59
+ [package_json, version_file]
47
60
  end
48
61
 
49
- def to_version(type, version: nil, value: nil)
62
+ # ef version_replacement
63
+ # match = GSUB_REGEX.match(File.readlines
64
+ # end
65
+
66
+ def to_version(type, version: nil)
50
67
  from = version
51
68
  match = VERSION_REGEX.match(from)
52
69
 
@@ -61,7 +78,7 @@ module TailwindCss
61
78
  #{groups.keys}"
62
79
  end
63
80
 
64
- groups[type] = value || (groups[type].to_i + 1).to_s
81
+ groups[type] = (groups[type].to_i + 1).to_s
65
82
 
66
83
  bump_to_zero(type, groups)
67
84
 
@@ -78,8 +95,8 @@ module TailwindCss
78
95
  groups[:minor] = "0"
79
96
  end
80
97
 
81
- def version_change(type, version: nil, value: nil)
82
- "Bumping from #{version} to #{to_version(type, version: version, value: value)}"
98
+ def version_change(type, version: nil)
99
+ "Bumping from #{version} to #{to_version(type, version: version)}"
83
100
  end
84
101
  end
85
102
  # rubocop:enable Metrics/BlockLength
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TailwindCss
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.13"
5
5
  end
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bridgetown-plugin-tailwindcss",
3
- "version": "0.1.2",
3
+ "version": "0.1.13",
4
4
  "main": "frontend/javascript/index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,9 +13,9 @@
13
13
  "files": [
14
14
  "frontend"
15
15
  ],
16
- "devDependencies": {
17
- "postcss-import": "^0.1.2",
18
- "postcss-loader": "^0.1.2",
19
- "tailwindcss": "^0.1.2"
16
+ "dependencies": {
17
+ "postcss-import": "^12.0.1",
18
+ "postcss-loader": "^3.0.0",
19
+ "tailwindcss": "^1.4.6"
20
20
  }
21
21
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown-plugin-tailwindcss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konnor Rogers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-31 00:00:00.000000000 Z
11
+ date: 2020-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bridgetown
@@ -140,7 +140,7 @@ homepage: https://github.com/paramagicdev/bridgetown-plugin-tailwindcss
140
140
  licenses:
141
141
  - MIT
142
142
  metadata:
143
- yarn-add: bridgetown-plugin-tailwindcss@0.1.2
143
+ yarn-add: bridgetown-plugin-tailwindcss@0.1.13
144
144
  post_install_message:
145
145
  rdoc_options: []
146
146
  require_paths: