@digigov/postcss-banner 0.3.8
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.
- package/CHANGELOG.json +17 -0
- package/CHANGELOG.md +11 -0
- package/README.md +101 -0
- package/index.js +34 -0
- package/package.json +31 -0
package/CHANGELOG.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@digigov/postcss-banner",
|
|
3
|
+
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.3.8",
|
|
6
|
+
"tag": "@digigov/postcss-banner_v0.3.8",
|
|
7
|
+
"date": "Thu, 30 Dec 2021 12:54:03 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Initial release for forked postcss-banner plugin"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Change Log - @digigov/postcss-banner
|
|
2
|
+
|
|
3
|
+
This log was last generated on Thu, 30 Dec 2021 12:54:03 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.3.8
|
|
6
|
+
Thu, 30 Dec 2021 12:54:03 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- Initial release for forked postcss-banner plugin
|
|
11
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# @digigov/postcss-banner
|
|
2
|
+
|
|
3
|
+
`postcss-banner` plugin to add text banner and footer to resulting file.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
* Asterisks to beginning of line are added automatically (use `inline: false` to disable)
|
|
8
|
+
* Bang isn't added automatically (use `important: true` to enable)
|
|
9
|
+
|
|
10
|
+
Add PostCSS Banner to your build tool:
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install --save-dev postcss postcss-banner
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Set `banner` and/or `footer` properties to add banner and/or footer to your
|
|
17
|
+
resulting css (so use after minifier).
|
|
18
|
+
|
|
19
|
+
Example:
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
postcss(require('postcss-banner')({banner: 'banner'}))
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
yields
|
|
26
|
+
|
|
27
|
+
```css
|
|
28
|
+
/*
|
|
29
|
+
* banner
|
|
30
|
+
*/
|
|
31
|
+
.foo {
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Value will be converted to string and wrapped with spaces by default.
|
|
36
|
+
Set `inline` to `true` to render the comment in a single line.
|
|
37
|
+
|
|
38
|
+
Example:
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
var postcss = require('gulp-postcss');
|
|
42
|
+
var postcssBanner = require('postcss-banner');
|
|
43
|
+
|
|
44
|
+
var banner = 'single line comment';
|
|
45
|
+
|
|
46
|
+
gulp.task('css', function () {
|
|
47
|
+
return gulp.src('./css/src/*.css')
|
|
48
|
+
.pipe(postcss(
|
|
49
|
+
[
|
|
50
|
+
postcssBanner({
|
|
51
|
+
banner: banner,
|
|
52
|
+
inline: true
|
|
53
|
+
})
|
|
54
|
+
]))
|
|
55
|
+
.pipe(gulp.dest('./css'));
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
yields
|
|
60
|
+
|
|
61
|
+
```css
|
|
62
|
+
/* single line comment */
|
|
63
|
+
.foo {
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Options
|
|
68
|
+
|
|
69
|
+
### `banner`
|
|
70
|
+
|
|
71
|
+
Type: `String`
|
|
72
|
+
|
|
73
|
+
The string will be converted in a css comment and put at the
|
|
74
|
+
beginning of the css file.
|
|
75
|
+
|
|
76
|
+
### `footer`
|
|
77
|
+
|
|
78
|
+
Type: `String`
|
|
79
|
+
|
|
80
|
+
The string will be converted in a css comment and put at the
|
|
81
|
+
end of the css file.
|
|
82
|
+
|
|
83
|
+
### `inline`
|
|
84
|
+
|
|
85
|
+
Type: `Boolean`
|
|
86
|
+
|
|
87
|
+
Default: `false`
|
|
88
|
+
|
|
89
|
+
Render the banner all in one line.
|
|
90
|
+
|
|
91
|
+
### `important`
|
|
92
|
+
|
|
93
|
+
Type: `Boolean`
|
|
94
|
+
|
|
95
|
+
Default: `false`
|
|
96
|
+
|
|
97
|
+
Add a bang to the comment. (eg. `/*! banner v.0.0.1 */`)
|
|
98
|
+
|
|
99
|
+
NOTE: Important css comments are generally preserved from being removed
|
|
100
|
+
during a minification process.
|
|
101
|
+
|
package/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module.exports = (opts = {}) => {
|
|
2
|
+
function makeComment(banner) {
|
|
3
|
+
const bang = opts.important ? '!' : '';
|
|
4
|
+
|
|
5
|
+
if (opts.inline) {
|
|
6
|
+
return `/*${bang} ${banner} */`;
|
|
7
|
+
}
|
|
8
|
+
return `/*${bang}
|
|
9
|
+
${banner.replace(/^|\n/g, '$& * ')}
|
|
10
|
+
*/`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
postcssPlugin: 'postcss-banner',
|
|
15
|
+
Once(css) {
|
|
16
|
+
if ('banner' in opts) {
|
|
17
|
+
css.prepend(makeComment(opts.banner));
|
|
18
|
+
|
|
19
|
+
// New line after banner
|
|
20
|
+
if (css.nodes[1]) {
|
|
21
|
+
// eslint-disable-next-line no-param-reassign
|
|
22
|
+
css.nodes[1].raws.before = '\n';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if ('footer' in opts) {
|
|
27
|
+
css.append(makeComment(opts.footer));
|
|
28
|
+
// eslint-disable-next-line no-param-reassign
|
|
29
|
+
css.nodes[css.nodes.length - 1].raws.before = '\n';
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
module.exports.postcss = true;
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@digigov/postcss-banner",
|
|
3
|
+
"version": "0.3.8",
|
|
4
|
+
"description": "PostCSS plugin to add text banner to resulting file",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"postcss",
|
|
7
|
+
"css",
|
|
8
|
+
"postcssplugin",
|
|
9
|
+
"banner",
|
|
10
|
+
"footer"
|
|
11
|
+
],
|
|
12
|
+
"author": "GRNET Devs",
|
|
13
|
+
"files": [
|
|
14
|
+
"index.js"
|
|
15
|
+
],
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"postcss": "8.2.6"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"chai": "4",
|
|
21
|
+
"eslint": "~7.24.0",
|
|
22
|
+
"eslint-config-airbnb-base": "^14.1.0",
|
|
23
|
+
"eslint-plugin-import": "2.20.1",
|
|
24
|
+
"mocha": "5",
|
|
25
|
+
"prettier": "~2.2.1",
|
|
26
|
+
"@digigov/cli-lint": "0.5.25"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"test": "eslint *.js test/*.js && mocha"
|
|
30
|
+
}
|
|
31
|
+
}
|