jekyll-postcss 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/CHANGELOG.md +4 -0
- data/README.md +2 -2
- data/bin/postcss +41 -22
- data/lib/jekyll-postcss/socket.rb +43 -9
- data/lib/jekyll-postcss/version.rb +1 -1
- data/package.json +10 -0
- data/yarn.lock +8 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 635d3d12852e6842c6d3b24493c98b986578b6209ad1628c7005e4ea7f3db7ce
|
4
|
+
data.tar.gz: bbafa3ff24e1186926a16ca4c9d9ae240035d95ded1e5e9005c814fe777e780f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcb25b23596d06b8703b9a72697e614f7733ef7c07ece2ae4537934f4758c478bef4569da98bf99f0ccedfc1d8049d8d6782c349f69685a20f11ac1821004369
|
7
|
+
data.tar.gz: 669475b69a173d0aab8ea11aba25f40fadc68167ab0c099e95d94757032eefdbcce8441b487fadb5bbd00e5164e43c94d4953bbd4fa561391cf16744a9f6d609
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -43,9 +43,9 @@ module.exports = {
|
|
43
43
|
|
44
44
|
All files with the `.css` extension will now be processed by PostCSS.
|
45
45
|
|
46
|
-
###
|
46
|
+
### Notes
|
47
47
|
|
48
|
-
|
48
|
+
jekyll-postcss will run a development server when `JEKYLL_ENV` is set to `development`. This is the default value if you don't set it elsewhere. When building your site for production or staging, make sure to set the `JEKYLL_ENV` appropriately, or else your deploy may fail, e.g., `JEKYLL_ENV=production bundle exec jekyll build`.
|
49
49
|
|
50
50
|
Also note that your `.css` files still need to have a [front matter](https://jekyllrb.com/docs/step-by-step/03-front-matter/) for them to be processed by Jekyll.
|
51
51
|
|
data/bin/postcss
CHANGED
@@ -1,31 +1,50 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
|
3
|
-
const postcss = require(require.resolve("postcss", {paths: [process.cwd()]}));
|
3
|
+
const postcss = require(require.resolve("postcss", { paths: [process.cwd()] }));
|
4
4
|
const config = require(`${process.cwd()}/postcss.config.js`);
|
5
5
|
const net = require("net");
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
class PostCSS {
|
8
|
+
static process(data, write) {
|
9
9
|
postcss(config.plugins)
|
10
|
-
.process(JSON.parse(data).raw_content, {from: "stdin"})
|
11
|
-
.then(result =>
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
return;
|
16
|
-
})
|
17
|
-
.catch(error => {
|
18
|
-
console.log("PostCSS Error!\n");
|
19
|
-
console.log(error.toString());
|
10
|
+
.process(JSON.parse(data).raw_content, { from: "stdin" })
|
11
|
+
.then((result) => write(result))
|
12
|
+
.catch((error) => {
|
13
|
+
console.error("PostCSS Error!\n");
|
14
|
+
console.error(error.toString());
|
20
15
|
});
|
21
|
-
}
|
22
|
-
});
|
16
|
+
}
|
23
17
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
18
|
+
static startServer() {
|
19
|
+
const server = net.createServer((c) => {
|
20
|
+
c.on("data", (data) => {
|
21
|
+
this.process(data, function (result) {
|
22
|
+
const packet = { compiled_css: result.toString() };
|
28
23
|
|
29
|
-
|
30
|
-
|
31
|
-
});
|
24
|
+
c.write(`${JSON.stringify(packet)}\n`);
|
25
|
+
});
|
26
|
+
});
|
27
|
+
});
|
28
|
+
|
29
|
+
server.on("error", (err) => {
|
30
|
+
console.error("PostCSS Server Error!\n");
|
31
|
+
throw err;
|
32
|
+
});
|
33
|
+
|
34
|
+
server.listen(8124, () => {
|
35
|
+
console.log("PostCSS Server listening on port 8124...");
|
36
|
+
});
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
switch (process.argv[2]) {
|
41
|
+
case "--development":
|
42
|
+
PostCSS.startServer();
|
43
|
+
break;
|
44
|
+
default:
|
45
|
+
PostCSS.process(process.argv[2], function (result) {
|
46
|
+
const packet = { compiled_css: result.toString() };
|
47
|
+
|
48
|
+
process.stdout.write(`${JSON.stringify(packet)}`);
|
49
|
+
});
|
50
|
+
}
|
@@ -2,15 +2,57 @@
|
|
2
2
|
|
3
3
|
require "socket"
|
4
4
|
require "json"
|
5
|
+
require "open3"
|
5
6
|
|
6
7
|
module PostCss
|
7
8
|
class Socket
|
9
|
+
class PostCssRuntimeError; end
|
8
10
|
START_SCRIPT = File.expand_path("../../bin/command", __dir__)
|
9
11
|
POSTCSS_SCRIPT = File.expand_path("../../bin/postcss", __dir__)
|
10
12
|
|
11
13
|
def initialize
|
14
|
+
start_dev_server if development?
|
15
|
+
end
|
16
|
+
|
17
|
+
def write(data)
|
18
|
+
if development?
|
19
|
+
@postcss.puts encode(data)
|
20
|
+
else
|
21
|
+
@compiled_css = `#{POSTCSS_SCRIPT} '#{encode(data)}'`
|
22
|
+
end
|
23
|
+
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def read
|
28
|
+
if development?
|
29
|
+
decode(@postcss.gets.chomp)
|
30
|
+
else
|
31
|
+
raise "You must call PostCss#write before calling PostCss#read" if @compiled_css.nil?
|
32
|
+
|
33
|
+
@compiled_css
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def encode(data)
|
40
|
+
JSON.dump(:raw_content => data)
|
41
|
+
end
|
42
|
+
|
43
|
+
def decode(data)
|
44
|
+
JSON.parse(data)["compiled_css"]
|
45
|
+
end
|
46
|
+
|
47
|
+
def development?
|
48
|
+
@env ||= Jekyll.env
|
49
|
+
|
50
|
+
@env == "development"
|
51
|
+
end
|
52
|
+
|
53
|
+
def start_dev_server
|
12
54
|
Thread.new do
|
13
|
-
system "#{START_SCRIPT} #{POSTCSS_SCRIPT}"
|
55
|
+
system "#{START_SCRIPT} #{POSTCSS_SCRIPT} --development"
|
14
56
|
end
|
15
57
|
|
16
58
|
@postcss = nil
|
@@ -22,13 +64,5 @@ module PostCss
|
|
22
64
|
end
|
23
65
|
end
|
24
66
|
end
|
25
|
-
|
26
|
-
def write(data)
|
27
|
-
@postcss.puts JSON.dump(:raw_content => data)
|
28
|
-
end
|
29
|
-
|
30
|
-
def read
|
31
|
-
JSON.parse(@postcss.gets.chomp)["compiled_css"]
|
32
|
-
end
|
33
67
|
end
|
34
68
|
end
|
data/package.json
ADDED
data/yarn.lock
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
2
|
+
# yarn lockfile v1
|
3
|
+
|
4
|
+
|
5
|
+
prettier@^2.0.5:
|
6
|
+
version "2.0.5"
|
7
|
+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4"
|
8
|
+
integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-postcss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mitchell Hanberg
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -107,6 +107,8 @@ files:
|
|
107
107
|
- lib/jekyll-postcss/socket.rb
|
108
108
|
- lib/jekyll-postcss/version.rb
|
109
109
|
- lib/jekyll/converters/postcss.rb
|
110
|
+
- package.json
|
111
|
+
- yarn.lock
|
110
112
|
homepage: https://github.com/mhanberg/jekyll-postcss
|
111
113
|
licenses:
|
112
114
|
- MIT
|