@videinfra/static-website-builder 1.3.2 → 1.4.3

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.md CHANGED
@@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## [1.4.3] - 2022-03-08
8
+ ### Fixed
9
+ - Fixed negative glob paths not working
10
+
11
+ ## [1.4.2] - 2021-08-27
12
+ ### Fixed
13
+ - Fixed postcss-ignore-plugin only removing and adding content in unrelated files
14
+
15
+ ## [1.4.1] - 2021-05-20
16
+ ### Fixed
17
+ - Enabled postcss-ignore-plugin only when cssnano is used
18
+
19
+ ## [1.4.0] - 2021-05-20
20
+ ### Added
21
+ - Added postcss-ignore-plugin
22
+
7
23
  ## [1.3.2] - 2021-04-07
8
24
  ### Added
9
25
  - Added gulp-dependents plugin to the .scss files for faster builds
@@ -22,7 +22,10 @@ class GlobObject {
22
22
  if (this.pathsArr.length) {
23
23
  this.map((basePath) => {
24
24
  return pathsArr.map((subPath) => {
25
- return path.join(basePath, subPath);
25
+ // If subpath starts with specia character "!" then prepend that to the begining of full paths
26
+ const negativePath = subPath[0] === '!' ? '!' : '';
27
+ const subPathNormalized = negativePath ? subPath.substr(1) : subPath;
28
+ return negativePath + path.join(basePath, subPathNormalized);
26
29
  });
27
30
  });
28
31
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@videinfra/static-website-builder",
3
- "version": "1.3.2",
3
+ "version": "1.4.3",
4
4
  "description": "Customizable static site project builder",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -26,6 +26,7 @@
26
26
  "dependencies": {
27
27
  "@babel/core": "^7.12.3",
28
28
  "@babel/preset-env": "^7.12.1",
29
+ "autoprefixer": "^9.6.1",
29
30
  "babel-loader": "^8.2.1",
30
31
  "browser-sync": "^2.26.13",
31
32
  "chalk": "4.0.0",
@@ -34,21 +35,18 @@
34
35
  "cssnano": "^4.1.10",
35
36
  "del": "^5.1.0",
36
37
  "gulp": "^4.0.2",
37
- "gulp-autoprefixer": "^7.0.1",
38
38
  "gulp-cached": "^1.1.1",
39
39
  "gulp-data": "^1.3.1",
40
- "gulp-debug": "^4.0.0",
41
40
  "gulp-dependents": "^1.2.5",
42
41
  "gulp-htmlmin": "^5.0.1",
43
42
  "gulp-if": "^3.0.0",
44
43
  "gulp-ignore": "^3.0.0",
45
44
  "gulp-plumber": "^1.2.1",
46
45
  "gulp-postcss": "^8.0.0",
47
- "gulp-remember": "^1.0.1",
48
46
  "gulp-sass": "^4.1.0",
49
47
  "gulp-sizereport": "^1.2.1",
50
- "gulp-sourcemaps": "^2.6.5",
51
- "gulp-svgmin": "^2.2.0",
48
+ "gulp-sourcemaps": "^3.0.0",
49
+ "gulp-svgmin": "^3.0.0",
52
50
  "gulp-svgstore": "^7.0.1",
53
51
  "gulp-twig": "^1.2.0",
54
52
  "minimist": "^1.2.5",
@@ -1,5 +1,5 @@
1
- module.exports = function dataLoaderJS (fileName) {
2
- // Re-load script each time this function is called
3
- delete require.cache[require.resolve(fileName)];
4
- return require(fileName);
5
- };
1
+ module.exports = function dataLoaderJS (fileName) {
2
+ // Re-load script each time this function is called
3
+ delete require.cache[require.resolve(fileName)];
4
+ return require(fileName);
5
+ };
@@ -2,7 +2,6 @@ const cssnano = require('cssnano');
2
2
  const autoprefixer = require('autoprefixer');
3
3
  const find = require('lodash/find');
4
4
 
5
-
6
5
  /**
7
6
  * Modify configuration
8
7
  *
@@ -17,19 +16,29 @@ module.exports = function processStylesheetsConfig (config, fullConfig) {
17
16
  }
18
17
 
19
18
  if (config && config.postcss) {
20
- config.postcss.plugins = config.postcss.plugins || {};
19
+ config.postcss.plugins = config.postcss.plugins || [];
21
20
 
22
21
  // Add autoprefixer
23
22
  if (config.autoprefixer && !find(config.postcss.plugins, {'postcssPlugin': 'autoprefixer'})) {
24
23
  config.postcss.plugins.push(autoprefixer(config.autoprefixer));
25
24
  }
26
25
 
27
- // Add CSS nano
26
+ if (config.cssnano) {
27
+ // Add ignore plugin only if there is nano / minification
28
+ config.postcss.plugins.unshift(require('../../vendor/postcss-ignore-plugin/dist/remove').default);
29
+ }
30
+
31
+ // // Add CSS nano
28
32
  if (config.cssnano && !find(config.postcss.plugins, {'postcssPlugin': 'cssnano'})) {
29
33
  config.postcss.plugins.push(cssnano({
30
34
  preset: [config.cssnano.preset, config.cssnano]
31
35
  }));
32
36
  }
37
+
38
+ if (config.cssnano) {
39
+ // Add ignore plugin only if there is nano / minification
40
+ config.postcss.plugins.push(require('../../vendor/postcss-ignore-plugin/dist/add').default);
41
+ }
33
42
  }
34
43
 
35
44
  return config;
@@ -84,6 +84,11 @@ test('glob map', () => {
84
84
  expect(output2).toEqual(['/a/some/folder/b', '/a/other/folder/b']);
85
85
  });
86
86
 
87
+ test('glob negative', () => {
88
+ const output = glob.paths('/some/folder').paths('!/assets/**/*.*').generate();
89
+ expect(output).toEqual(['!/some/folder/assets/**/*.*']);
90
+ });
91
+
87
92
  test('glob generate', () => {
88
93
  const output = glob.generate(
89
94
  glob.paths(['/a', '/b']).allFiles(),
@@ -0,0 +1,124 @@
1
+ # postcss-ignore-plugin
2
+
3
+ ![CI tests](https://github.com/anikethsaha/postcss-ignore-plugin/workflows/CI%20tests/badge.svg?branch=master&event=push)
4
+ ![CI Integration tests](https://github.com/anikethsaha/postcss-ignore-plugin/workflows/CI%20Integration%20tests/badge.svg?branch=master&event=push)
5
+
6
+ Ignore postcss plugins operations in lines using comments
7
+
8
+ ## Getting started
9
+
10
+ `$ yarn add postcss-ignore-plugin -D`
11
+
12
+ and add this it in your `postcss` config
13
+
14
+ ```js
15
+ // postcss.config.js
16
+ module.exports = {
17
+ plugins: [
18
+ require('postcss-ignore-plugin/remove'), // Important to keep this at the top of the plugins
19
+ require('cssnano'),
20
+ require('autoprefixer'),
21
+ require('stylelint'),
22
+ require('postcss-ignore-plugin/add'), // Important to keep it at the end
23
+ ],
24
+ };
25
+ ```
26
+
27
+ Now use the following comments whenever you want to ignore any operation for other plugins
28
+
29
+ - for ignoring a particular line or declaration (css properties) inside of css rule
30
+
31
+ ```css
32
+ /* postcss-ignore-line */
33
+ ```
34
+
35
+ > Dont use `/* postcss-ignore-line */` for css rules
36
+
37
+ - for ignoring a whole rule
38
+
39
+ ```css
40
+ /* postcss-ignore */
41
+ ```
42
+
43
+ ## How it works
44
+
45
+ Currently we support only for declaration statement, that mean you can add this comment over CSS declaration line not over the selector list in Rule declaration
46
+
47
+ `example`
48
+
49
+ ```css
50
+ .classname {
51
+ margin: auto;
52
+ /* postcss-ignore-line */
53
+ color: red;
54
+ }
55
+
56
+ /* postcss-ignore */
57
+ .classname {
58
+ margin: auto;
59
+ color: red;
60
+ }
61
+
62
+ @media screen and (min-width: 480px) {
63
+ ul {
64
+ /* postcss-ignore-line */
65
+ list-style: none;
66
+ }
67
+
68
+ /* postcss-ignore */
69
+ p {
70
+ font-size: 10px;
71
+ }
72
+ }
73
+ ```
74
+
75
+ It simple remove the next line before running the other plugins and then add them at the end.
76
+
77
+ ## Rules
78
+
79
+ Use [`stylelint-postcss-ignore`](https://github.com/anikethsaha/stylelint-postcss-ignore) for rules regarding this plugin 's better use
80
+
81
+ ## Tests
82
+
83
+ this plugins are tested with
84
+
85
+ - cssnano
86
+ - Autoprefixer
87
+ - postcss-preset-env
88
+ - stylelint
89
+ - some custom plugins meant to fail the op
90
+ - Indivial tests for each plugins
91
+
92
+ > There are not many test cases. More will be added soon
93
+
94
+ ## FAQ
95
+
96
+ - **Can we ignore a whole css `atrules` (like media queries) ?**
97
+
98
+ No, you need to use `/* postcss-ignore */` before each rule inside the `atrules`
99
+
100
+ - **will those ignore rules/properties (declarations) will come back to there original position after all operations?**
101
+
102
+ No, both. rules and atrules will append at the end. declarations (rules's properties) will append at the rule itself. and if you have used `/* postcss-ignore */` for a rule inside of atrules, it will get appended for that atrule at the end
103
+
104
+ - **Does it effect the performance like the build time?**
105
+
106
+ Yes _(sometimes for code with many ignore comments )_, but not at a huge level. It slightly decreases the performance as there are 2-3 nested looks so you can notices some issue with huge code with many ignore comments
107
+
108
+ ## Contributing Guidelines
109
+
110
+ Simply click on this
111
+
112
+ [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/anikethsaha/postcss-ignore-plugin)
113
+
114
+ and starting working in it !
115
+
116
+ **OR**
117
+
118
+ - clone the repo
119
+ - Install the dependenices `yarn install`
120
+ - Build the code `yarn build`
121
+ - run the tests before working `yarn test:only` and `yarn test:integrations`
122
+ - start working
123
+
124
+ If you add a new feature or did some breaking change , update [`stylelint-postcss-ignore`](https://github.com/anikethsaha/stylelint-postcss-ignore) for consistency
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _postcss = require("postcss");
9
+
10
+ var _default = (0, _postcss.plugin)('postcss-ignore-plugin-add', () => {
11
+ return (root, result) => {
12
+ if (result.messages.type !== 'postcss-ignore-plugin') {
13
+ return;
14
+ }
15
+
16
+ const msgs = result.messages;
17
+ let declToAdd = [],
18
+ rulesToAdd = [];
19
+ msgs.forEach(msg => {
20
+ if (msg['postcss-ignore-plugin'] !== undefined) {
21
+ msg['postcss-ignore-plugin'].ignoredLineData.forEach(ignoreData => {
22
+ if (root.source.input.file === ignoreData.fileName) {
23
+ declToAdd.push(ignoreData);
24
+ }
25
+ });
26
+ msg['postcss-ignore-plugin'].ignoreRulesData.forEach(ignoredRule => {
27
+ if (root.source.input.file === ignoredRule.fileName) {
28
+ rulesToAdd.push(ignoredRule);
29
+ }
30
+ });
31
+ }
32
+ }); // add decl to atrules
33
+
34
+ root.walkAtRules(atRules => {
35
+ declToAdd.forEach(decl => {
36
+ if (decl.atRule !== undefined && atRules.name === decl.atRule.name && atRules.params === decl.atRule.params) {
37
+ atRules.walkRules(rules => {
38
+ if (rules.selector === decl.selector) {
39
+ rules.append({
40
+ prop: decl.prop,
41
+ value: decl.value
42
+ });
43
+ }
44
+ });
45
+ }
46
+ });
47
+ }); // add decl only those with no atrules
48
+
49
+ root.walkRules(rules => {
50
+ declToAdd.forEach(decl => {
51
+ if (rules.selector === decl.selector && decl.atRule === undefined) {
52
+ rules.append({
53
+ prop: decl.prop,
54
+ value: decl.value
55
+ });
56
+ }
57
+ });
58
+ }); // add rules
59
+
60
+ rulesToAdd = rulesToAdd.filter(rule => {
61
+ if (rule.parent.type !== 'atrule') {
62
+ root.append(rule.rule);
63
+ return false;
64
+ }
65
+
66
+ return true;
67
+ }); // add rules to artules
68
+
69
+ root.walkAtRules(atrule => {
70
+ rulesToAdd = rulesToAdd.filter(rule => {
71
+ if (atrule.params === rule.parent.params) {
72
+ atrule.append(rule.rule);
73
+ return false;
74
+ }
75
+
76
+ return true;
77
+ });
78
+ });
79
+ };
80
+ });
81
+
82
+ exports.default = _default;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _postcss = require("postcss");
9
+
10
+ var _default = (0, _postcss.plugin)('postcss-ignore-plugin-remove', () => {
11
+ let ignoredLineData = [];
12
+ let commentsIgnoredRule = [];
13
+ let ignoreRulesData = []; // Work with options here
14
+
15
+ return (root, result) => {
16
+ // Transform CSS AST here
17
+ root.walkRules(rule => {
18
+ // Transform each rule here
19
+ rule.walkComments(comment => {
20
+ if (comment.text === 'postcss-ignore-line') {
21
+ let commentData = {
22
+ fileName: comment.source.input.file,
23
+ commentedLine: comment.source.start.line,
24
+ ignoredLine: comment.source.start.line + 1
25
+ };
26
+ comment.remove();
27
+ ignoredLineData.push(commentData);
28
+ }
29
+ });
30
+ });
31
+ root.walkComments(comment => {
32
+ if (comment.text === 'postcss-ignore') {
33
+ commentsIgnoredRule.push({
34
+ fileName: comment.source.input.file,
35
+ commentLine: comment.source.start,
36
+ ruleIgnoreLineNo: comment.source.start.line + 1
37
+ });
38
+
39
+ comment.remove();
40
+ }
41
+ });
42
+ root.walkRules(rule => {
43
+ rule.walkDecls(decl => {
44
+ const declLine = decl.source.start.line;
45
+ ignoredLineData.forEach(ignoreData => {
46
+ if (decl.source.input.file === ignoreData.fileName && ignoreData.ignoredLine === declLine) {
47
+ ignoreData.selector = decl.parent.selector;
48
+ ignoreData.prop = decl.prop;
49
+ ignoreData.value = decl.value;
50
+
51
+ if (decl.parent.parent.type === 'atrule') {
52
+ ignoreData.atRule = {
53
+ name: decl.parent.parent.name,
54
+ params: decl.parent.parent.params
55
+ };
56
+ }
57
+
58
+ decl.remove();
59
+ }
60
+ });
61
+ });
62
+ commentsIgnoredRule.forEach(data => {
63
+ if (rule.source.input.file === data.fileName && rule.source.start.line === data.ruleIgnoreLineNo) {
64
+ ignoreRulesData.push({
65
+ rule,
66
+ parent: rule.parent,
67
+ fileName: data.fileName
68
+ });
69
+ rule.remove();
70
+ }
71
+ });
72
+ });
73
+ result.messages.type = 'postcss-ignore-plugin';
74
+ result.messages.push({
75
+ 'postcss-ignore-plugin': {
76
+ ignoredLineData,
77
+ ignoreRulesData
78
+ }
79
+ });
80
+ };
81
+ });
82
+
83
+ exports.default = _default;