@videinfra/static-website-builder 1.6.4 → 1.8.0

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,19 @@ 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.8.0] - 2023-08-10
8
+ ### Updated
9
+ - Dependencies
10
+ ### Removed
11
+ - postcss-ignore-plugin
12
+ ### Added
13
+ - CSS tests
14
+
15
+ ## [1.7.0] - 2023-05-25
16
+ ### Updated
17
+ - Depedencies
18
+ - Added autoprefixer test
19
+
7
20
  ## [1.6.4] - 2023-03-29
8
21
  ### Updated
9
22
  - Added stylesheet source path to the default include paths
@@ -0,0 +1,3 @@
1
+ main {
2
+ clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
3
+ }
@@ -0,0 +1,4 @@
1
+ :root {
2
+ --yes: ;
3
+ --no: initial;
4
+ }
@@ -0,0 +1,3 @@
1
+ body {
2
+ padding-top: calc(10vw + calc(10vh * 1.5));
3
+ }
package/lib/get-path.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const path = require('path');
2
- const memoize = require('nano-memoize');
2
+ const memoize = require('nano-memoize').default;
3
3
  const getConfig = require('./get-config');
4
4
 
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@videinfra/static-website-builder",
3
- "version": "1.6.4",
3
+ "version": "1.8.0",
4
4
  "description": "Customizable static site project builder",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -25,15 +25,16 @@
25
25
  "test-watch": "gulp --config=init/test/config/config.js"
26
26
  },
27
27
  "dependencies": {
28
- "@babel/core": "^7.17.9",
29
- "@babel/preset-env": "^7.16.11",
30
- "autoprefixer": "^9.8.8",
31
- "babel-loader": "^8.2.4",
32
- "browser-sync": "^2.27.9",
28
+ "@babel/core": "^7.21.8",
29
+ "@babel/preset-env": "^7.21.5",
30
+ "@csstools/postcss-nested-calc": "^3.0.0",
31
+ "autoprefixer": "^10.4.14",
32
+ "babel-loader": "^8.3.0",
33
+ "browser-sync": "^2.29.3",
33
34
  "chalk": "4.0.0",
34
35
  "chokidar": "^3.5.3",
35
36
  "cross-env": "^7.0.3",
36
- "cssnano": "^4.1.11",
37
+ "cssnano": "^6.0.1",
37
38
  "del": "^6.0.0",
38
39
  "gulp": "^4.0.2",
39
40
  "gulp-cached": "^1.1.1",
@@ -43,21 +44,21 @@
43
44
  "gulp-if": "^3.0.0",
44
45
  "gulp-ignore": "^3.0.0",
45
46
  "gulp-plumber": "^1.2.1",
46
- "gulp-postcss": "^8.0.0",
47
+ "gulp-postcss": "^9.0.1",
47
48
  "gulp-sass": "^5.1.0",
48
49
  "gulp-sizereport": "^1.2.1",
49
50
  "gulp-sourcemaps": "^3.0.0",
50
51
  "gulp-svgmin": "^4.1.0",
51
52
  "gulp-svgstore": "^9.0.0",
52
53
  "gulp-twig": "^1.2.0",
53
- "minimist": "^1.2.6",
54
- "nano-memoize": "1.3.0",
55
- "node-sass": "^7.0.1",
56
- "sass": "^1.52.3",
54
+ "minimist": "^1.2.8",
55
+ "nano-memoize": "3.0.13",
56
+ "node-sass": "^7.0.3",
57
+ "sass": "^1.65.1",
57
58
  "webpack": "^4.46.0",
58
59
  "webpack-stream": "^5.2.1"
59
60
  },
60
61
  "devDependencies": {
61
- "jest": "^27.5.1"
62
+ "jest": "^29.6.2"
62
63
  }
63
64
  }
@@ -1,5 +1,5 @@
1
1
  const gulp = require('gulp');
2
- const memoize = require('nano-memoize');
2
+ const memoize = require('nano-memoize').default;
3
3
 
4
4
  const globs = require('@videinfra/example-website-builder/lib/globs-helper');
5
5
  const getConfig = require('@videinfra/example-website-builder/lib/get-config');
@@ -1,5 +1,5 @@
1
1
  const gulp = require('gulp');
2
- const memoize = require('nano-memoize');
2
+ const memoize = require('nano-memoize').default;
3
3
 
4
4
  const globs = require('./../../lib/globs-helper');
5
5
  const getPaths = require('./../../lib/get-path');
@@ -2,7 +2,7 @@ const gulp = require('gulp');
2
2
  const data = require('gulp-data');
3
3
  const gulpif = require('gulp-if');
4
4
  const htmlmin = require('gulp-htmlmin')
5
- const memoize = require('nano-memoize');
5
+ const memoize = require('nano-memoize').default;
6
6
  const cached = require('gulp-cached');
7
7
  const dependents = require('gulp-dependents');
8
8
  const ignore = require('gulp-ignore');
@@ -2,7 +2,7 @@ const gulp = require('gulp');
2
2
  const gulpif = require('gulp-if');
3
3
  const svgstore = require('gulp-svgstore');
4
4
  const svgmin = require('gulp-svgmin');
5
- const memoize = require('nano-memoize');
5
+ const memoize = require('nano-memoize').default;
6
6
 
7
7
  const globs = require('./../../lib/globs-helper');
8
8
  const getPaths = require('./../../lib/get-path');
@@ -1,5 +1,5 @@
1
1
  const gulp = require('gulp');
2
- const memoize = require('nano-memoize');
2
+ const memoize = require('nano-memoize').default;
3
3
 
4
4
  const globs = require('./../../lib/globs-helper');
5
5
  const getPaths = require('./../../lib/get-path');
@@ -1,7 +1,7 @@
1
1
  const gulp = require('gulp');
2
2
  const webpack = require('webpack');
3
3
  const gulpWebpack = require('webpack-stream');
4
- const memoize = require('nano-memoize');
4
+ const memoize = require('nano-memoize').default;
5
5
 
6
6
  const merge = require('../../lib/merge');
7
7
  const globs = require('./../../lib/globs-helper');
@@ -1,5 +1,5 @@
1
1
  const gulp = require('gulp');
2
- const memoize = require('nano-memoize');
2
+ const memoize = require('nano-memoize').default;
3
3
 
4
4
  const globs = require('./../../lib/globs-helper');
5
5
  const getPaths = require('./../../lib/get-path');
@@ -15,6 +15,12 @@ exports.stylesheets = {
15
15
  autoprefixer: {
16
16
  },
17
17
 
18
+ // PostCSS Nested Calc
19
+ // see https://www.npmjs.com/package/@csstools/postcss-nested-calc
20
+ nestedCalc: {
21
+ preserve: false,
22
+ },
23
+
18
24
  // PostCSS plugins and options
19
25
  // see https://github.com/postcss/postcss
20
26
  postcss: {
@@ -1,5 +1,6 @@
1
1
  const cssnano = require('cssnano');
2
2
  const autoprefixer = require('autoprefixer');
3
+ const postcssNestedCalc = require('@csstools/postcss-nested-calc');
3
4
  const find = require('lodash/find');
4
5
 
5
6
  /**
@@ -18,27 +19,22 @@ module.exports = function processStylesheetsConfig (config, fullConfig) {
18
19
  if (config && config.postcss) {
19
20
  config.postcss.plugins = config.postcss.plugins || [];
20
21
 
22
+ // Add nestedCalc
23
+ if (config.nestedCalc) {
24
+ config.postcss.plugins.push(postcssNestedCalc(config.nestedCalc));
25
+ }
26
+
21
27
  // Add autoprefixer
22
28
  if (config.autoprefixer && !find(config.postcss.plugins, {'postcssPlugin': 'autoprefixer'})) {
23
29
  config.postcss.plugins.push(autoprefixer(config.autoprefixer));
24
30
  }
25
31
 
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
32
  // // Add CSS nano
32
33
  if (config.cssnano && !find(config.postcss.plugins, {'postcssPlugin': 'cssnano'})) {
33
34
  config.postcss.plugins.push(cssnano({
34
35
  preset: [config.cssnano.preset, config.cssnano]
35
36
  }));
36
37
  }
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
- }
42
38
  }
43
39
 
44
40
  return config;
@@ -2,7 +2,7 @@ const gulp = require('gulp');
2
2
  const gulpif = require('gulp-if');
3
3
  const postcss = require('gulp-postcss');
4
4
  const sourcemaps = require('gulp-sourcemaps');
5
- const memoize = require('nano-memoize');
5
+ const memoize = require('nano-memoize').default;
6
6
  const cached = require('gulp-cached');
7
7
  const dependents = require('gulp-dependents');
8
8
 
@@ -23,13 +23,31 @@ test('SASS variable test', () => {
23
23
 
24
24
  test('SASS import test', () => {
25
25
  return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/import-test.css'), {'encoding': 'utf8'}).then((css) => {
26
- expect(css).toBe('.btn{color:#fff;background:#222}');
26
+ expect(css).toBe('.btn{background:#222;color:#fff}');
27
27
  });
28
28
  });
29
29
 
30
30
  test('SASS sub-folder import test', () => {
31
31
  return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/sub-folder/import-test.css'), {'encoding': 'utf8'}).then((css) => {
32
- expect(css).toBe('.btn{color:#fff;background:#222}');
32
+ expect(css).toBe('.btn{background:#222;color:#fff}');
33
+ });
34
+ });
35
+
36
+ test('SASS autoprefixer test', () => {
37
+ return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/autoprefixer-test.css'), {'encoding': 'utf8'}).then((css) => {
38
+ expect(css).toBe('main{-webkit-clip-path:polygon(0 0,100% 0,100% 100%,0 100%);clip-path:polygon(0 0,100% 0,100% 100%,0 100%)}');
39
+ });
40
+ });
41
+
42
+ test('CSS nano ignore test', () => {
43
+ return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/ignore-test.css'), {'encoding': 'utf8'}).then((css) => {
44
+ expect(css).toBe(':root{--yes: ;--no:initial}');
45
+ });
46
+ });
47
+
48
+ test('CSS nano nested calc test', () => {
49
+ return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/nested-calc-test.css'), {'encoding': 'utf8'}).then((css) => {
50
+ expect(css).toBe('body{padding-top:calc(10vw + (10vh * 1.5))}');
33
51
  });
34
52
  });
35
53
 
@@ -1,124 +0,0 @@
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
@@ -1,82 +0,0 @@
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;
@@ -1,83 +0,0 @@
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;