bridgetown-plugin-tailwindcss 0.1.2 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -6
- data/Rakefile +1 -1
- data/lib/bridgetown-plugin-tailwindcss/command.rb +147 -82
- data/lib/bridgetown-plugin-tailwindcss/utils.rb +29 -12
- data/lib/bridgetown-plugin-tailwindcss/version.rb +1 -1
- data/package.json +5 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05c15d69195b9dfe1eb8047f2210d15f9fa57cefc846b3c98add0269fbb4b0da
|
4
|
+
data.tar.gz: be528c7167c5d0173c3af625e32c55b19df06fc07176bbfc10bfff04699fc1af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
```
|
58
|
-
|
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
@@ -3,102 +3,167 @@
|
|
3
3
|
require "bridgetown"
|
4
4
|
require_relative "utils"
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
24
|
+
private
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
def run
|
27
|
+
write_files
|
28
|
+
end
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
43
|
+
return unless File.exist?(frontend_stylesheet)
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
+
ACTIONS.prepend_to_file(frontend_stylesheet, import_tailwind_contents)
|
46
|
+
end
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
-
|
55
|
-
|
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
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
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
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
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
|
-
|
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,
|
33
|
+
gsub_file(file, GSUB_REGEX, gsub_string)
|
28
34
|
end
|
29
35
|
end
|
30
36
|
|
31
|
-
def bump_version(type, version: VERSION
|
32
|
-
say(version_change(type, version: version
|
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
|
-
|
36
|
-
|
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
|
-
|
44
|
-
|
56
|
+
package_json = File.expand_path("package.json")
|
57
|
+
version_file = File.expand_path(File.join(__dir__, "version.rb"))
|
45
58
|
|
46
|
-
[
|
59
|
+
[package_json, version_file]
|
47
60
|
end
|
48
61
|
|
49
|
-
|
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] =
|
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
|
82
|
-
"Bumping from #{version} to #{to_version(type, version: version
|
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
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "bridgetown-plugin-tailwindcss",
|
3
|
-
"version": "0.1.
|
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
|
-
"
|
17
|
-
"postcss-import": "^0.1
|
18
|
-
"postcss-loader": "^0.
|
19
|
-
"tailwindcss": "^
|
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.
|
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-
|
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.
|
143
|
+
yarn-add: bridgetown-plugin-tailwindcss@0.1.13
|
144
144
|
post_install_message:
|
145
145
|
rdoc_options: []
|
146
146
|
require_paths:
|