@zohodesk/react-cli 0.0.1-exp.162.3 → 0.0.1-exp.166.1
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/DOTO.md +13 -0
- package/README.md +29 -5
- package/bin/cli.js +22 -1
- package/docs/CustomChunks.md +26 -0
- package/docs/TODOS.md +10 -0
- package/docs/ValueReplacer.md +60 -0
- package/docs/warnings_while_install.txt +35 -0
- package/eslint/NOTES.md +3 -0
- package/eslint/a23.c +16 -0
- package/eslint/a28.c +25 -0
- package/eslint/a29.c +25 -0
- package/eslint/a30.c +29 -0
- package/eslint/a31.c +23 -0
- package/eslint/a35.c +23 -0
- package/eslint/a36.c +18 -0
- package/eslint/a37.c +25 -0
- package/eslint/a38.c +28 -0
- package/eslint/a39.c +17 -0
- package/eslint/a40.c +32 -0
- package/eslint/mockapi.html +18 -0
- package/eslint/mockapi.md +5 -0
- package/lib/common/splitChunks.js +66 -72
- package/lib/common/testPattern.js +69 -0
- package/lib/common/valueReplacer.js +55 -0
- package/lib/configs/jest.config.js +6 -1
- package/lib/configs/webpack.docs.config.js +31 -27
- package/lib/loaderUtils/getCSSLoaders.js +17 -13
- package/lib/postcss-plugins/ValueReplacer.js +46 -0
- package/lib/schemas/index.js +11 -0
- package/lib/servers/devBulid.js +98 -0
- package/lib/servers/getCliPath.js +24 -0
- package/lib/servers/nowatchserver.js +9 -84
- package/lib/servers/server.js +9 -2
- package/npm8.md +9 -0
- package/package.json +2 -2
@@ -7,9 +7,11 @@ exports.default = void 0;
|
|
7
7
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
9
9
|
|
10
|
+
var _os = _interopRequireDefault(require("os"));
|
11
|
+
|
10
12
|
var _utils = require("../utils");
|
11
13
|
|
12
|
-
var
|
14
|
+
var _testPattern = require("./testPattern");
|
13
15
|
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
17
|
|
@@ -39,91 +41,83 @@ let isReact = module => {
|
|
39
41
|
} = module;
|
40
42
|
let reactBundle = ['react', 'react-dom'];
|
41
43
|
return userRequest && reactBundle.some(pkg => userRequest.indexOf(`node_modules${ps}${pkg}${ps}`) >= 0);
|
42
|
-
};
|
43
|
-
// 'react.vendor': {
|
44
|
-
// name: 'react.vendor',
|
45
|
-
// chunks: 'all',
|
46
|
-
// minChunks: 1,
|
47
|
-
// test: isReact,
|
48
|
-
// priority: -10
|
49
|
-
// },
|
50
|
-
// vendor: {
|
51
|
-
// name: 'vendor',
|
52
|
-
// chunks: 'all',
|
53
|
-
// minChunks: 1,
|
54
|
-
// test: isVendor,
|
55
|
-
// priority: -10
|
56
|
-
// },
|
57
|
-
// zohocharts: {
|
58
|
-
// chunks: 'all',
|
59
|
-
// minChunks: 1,
|
60
|
-
// test: /[\\/]node_modules[\\/]((@zohodesk|@zohocharts))[\\/]((zc-custom|d3).*)/,
|
61
|
-
// priority: 30,
|
62
|
-
// enforce: true
|
63
|
-
// }
|
64
|
-
// };
|
65
|
-
|
44
|
+
};
|
66
45
|
|
67
46
|
let defaultChunks = {
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
priority: 19,
|
47
|
+
'react.vendor': {
|
48
|
+
name: 'react.vendor',
|
49
|
+
chunks: 'all',
|
50
|
+
minChunks: 1,
|
51
|
+
test: isReact,
|
74
52
|
enforce: true,
|
75
|
-
//
|
76
|
-
minSize: 30000 // use the default minSize
|
77
|
-
|
78
|
-
},
|
79
|
-
vendorsAsync: {
|
80
|
-
// vendors async chunk, remaining asynchronously used node modules as single chunk file
|
81
|
-
test: /[\\/]node_modules[\\/]((?!react).*)[\\/]/,
|
82
|
-
name: 'vendors.async',
|
83
|
-
chunks: 'async',
|
84
|
-
priority: 9,
|
85
|
-
reuseExistingChunk: true,
|
86
|
-
minSize: 10000 // use smaller minSize to avoid too much potential bundle bloat due to module duplication.
|
87
|
-
|
88
|
-
},
|
89
|
-
react: {
|
90
|
-
automaticNamePrefix: 'react',
|
91
|
-
test: /[\\/]node_modules[\\/]((react).*)[\\/]/,
|
53
|
+
// priority: 10
|
92
54
|
priority: -10
|
93
55
|
},
|
94
|
-
|
95
|
-
|
96
|
-
name: 'commons.async',
|
97
|
-
minChunks: 2,
|
98
|
-
// Minimum number of chunks that must share a module before splitting
|
99
|
-
chunks: 'async',
|
100
|
-
priority: -10,
|
101
|
-
reuseExistingChunk: true,
|
102
|
-
//minSize: 10000 // use smaller minSize to avoid too much potential bundle bloat due to module duplication.
|
103
|
-
minSize: 5000
|
104
|
-
},
|
105
|
-
zohocharts: {
|
56
|
+
vendor: {
|
57
|
+
name: 'vendor',
|
106
58
|
chunks: 'all',
|
59
|
+
// chunks: 'initial',
|
107
60
|
minChunks: 1,
|
108
|
-
test:
|
109
|
-
priority:
|
110
|
-
|
61
|
+
test: isVendor,
|
62
|
+
// priority: 19,
|
63
|
+
priority: -10
|
111
64
|
}
|
112
65
|
};
|
113
66
|
let customChunksConfig = {};
|
114
|
-
customChunks.map(({
|
67
|
+
customChunks.map((obj, index) => ({
|
68
|
+
name: obj.name,
|
69
|
+
pattern: obj.pattern,
|
70
|
+
minChunks: obj.minChunks || obj.size || 2,
|
71
|
+
rules: obj.rules,
|
72
|
+
// includeDepenency: obj.includeDepenency || false,
|
73
|
+
priority: obj.priority || -10 * (index + 2),
|
74
|
+
enforce: obj.enforce || true,
|
75
|
+
maxSize: obj.maxSize,
|
76
|
+
// || 0,
|
77
|
+
minSize: obj.minSize,
|
78
|
+
// || 20000,
|
79
|
+
chunks: obj.chunks || 'all'
|
80
|
+
})).map(({
|
115
81
|
name,
|
116
82
|
pattern,
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
83
|
+
minChunks,
|
84
|
+
rules,
|
85
|
+
priority,
|
86
|
+
// includeDepenency,
|
87
|
+
enforce,
|
88
|
+
minSize,
|
89
|
+
maxSize,
|
90
|
+
chunks = 'all'
|
91
|
+
}) => {
|
92
|
+
let obj = {
|
93
|
+
name,
|
94
|
+
test: rules ? m => {
|
95
|
+
const {
|
96
|
+
userRequest
|
97
|
+
} = m;
|
98
|
+
return (0, _testPattern.testPattern)(userRequest, rules); // return (
|
99
|
+
// pkgs.some(p => isRelated(userRequest, p)) ||
|
100
|
+
// (includeDepenency && isDependency(m, pkgs))
|
101
|
+
// );
|
102
|
+
} : new RegExp(isWindows ? pattern.replace(/\//g, '\\') : pattern),
|
103
|
+
chunks,
|
104
|
+
enforce,
|
105
|
+
minChunks,
|
106
|
+
priority
|
107
|
+
};
|
108
|
+
|
109
|
+
if (minSize !== undefined) {
|
110
|
+
obj.minSize = minSize;
|
111
|
+
}
|
112
|
+
|
113
|
+
if (maxSize !== undefined) {
|
114
|
+
obj.maxSize = maxSize;
|
115
|
+
}
|
116
|
+
|
117
|
+
return customChunksConfig[name] = obj;
|
125
118
|
});
|
126
119
|
var _default = {
|
120
|
+
minSize: 12000,
|
127
121
|
cacheGroups: Object.assign({
|
128
122
|
default: false,
|
129
123
|
vendors: false
|
@@ -0,0 +1,69 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.isDependency = isDependency;
|
7
|
+
exports.isRelatedPackage = exports.isRelated = void 0;
|
8
|
+
exports.testPattern = testPattern;
|
9
|
+
|
10
|
+
var _path = require("path");
|
11
|
+
|
12
|
+
// in our development we only use windows, mac and linux
|
13
|
+
const isWindows = _path.sep !== '/'; // this function will return true if pattern matched
|
14
|
+
|
15
|
+
function _testPattern(req, pattern) {
|
16
|
+
let modifyedPattern = pattern;
|
17
|
+
|
18
|
+
if (/[*.$^]/.test(modifyedPattern)) {
|
19
|
+
if (isWindows) {
|
20
|
+
// modifyedPattern = pattern.replace(/\//g, ps.replace(/\\/g, '\\\\'));
|
21
|
+
modifyedPattern = modifyedPattern.replace(/\//g, '\\\\');
|
22
|
+
}
|
23
|
+
|
24
|
+
modifyedPattern = modifyedPattern.replace(/\./g, '\\.').replace(/\*/g, '.*');
|
25
|
+
const re = new RegExp(modifyedPattern);
|
26
|
+
return re.test(req);
|
27
|
+
}
|
28
|
+
|
29
|
+
if (isWindows) {
|
30
|
+
// modifyedPattern = pattern.replace(/\//g, ps.replace(/\\/g, '\\\\'));
|
31
|
+
modifyedPattern = modifyedPattern.replace(/\//g, '\\');
|
32
|
+
}
|
33
|
+
|
34
|
+
return req.indexOf(modifyedPattern) !== -1;
|
35
|
+
}
|
36
|
+
|
37
|
+
function testPattern(req, pattern) {
|
38
|
+
if (!req || !pattern) {
|
39
|
+
return false;
|
40
|
+
}
|
41
|
+
|
42
|
+
if (Array.isArray(pattern)) {
|
43
|
+
// eslint-disable-next-line no-unused-vars
|
44
|
+
return pattern.every(p => testPattern(req, p));
|
45
|
+
}
|
46
|
+
|
47
|
+
if (pattern[0] === '!') {
|
48
|
+
return !_testPattern(req, pattern.slice(1));
|
49
|
+
}
|
50
|
+
|
51
|
+
return _testPattern(req, pattern);
|
52
|
+
}
|
53
|
+
|
54
|
+
const isRelated = (req, item) => req && req.indexOf(item) !== -1; // export const isRelated = (req, item) => testPattern(req, item);
|
55
|
+
|
56
|
+
|
57
|
+
exports.isRelated = isRelated;
|
58
|
+
|
59
|
+
const isRelatedPackage = (req, item) => isRelated(req, `node_modules${_path.sep}${item}${_path.sep}`) !== -1; // export const isRelated = (req, item) => testPattern(req, item);
|
60
|
+
|
61
|
+
|
62
|
+
exports.isRelatedPackage = isRelatedPackage;
|
63
|
+
|
64
|
+
function isDependency(m, excludeList) {
|
65
|
+
// let reasons = m.reasons.map(r => r.module.userRequest);
|
66
|
+
// m.reasons.some(r => !r.module || !r.module.userRequest) && console.log(m.reasons);
|
67
|
+
return m.reasons.some(r => excludeList.some(item => r.module && isRelated(r.module.userRequest, item)));
|
68
|
+
} // export function queryHandler(conditions, pattern) {
|
69
|
+
// }
|
@@ -0,0 +1,55 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _postcss = _interopRequireDefault(require("postcss"));
|
4
|
+
|
5
|
+
var _path = _interopRequireDefault(require("path"));
|
6
|
+
|
7
|
+
var _fs = _interopRequireDefault(require("fs"));
|
8
|
+
|
9
|
+
var _folderIterator = _interopRequireDefault(require("../utils/folderIterator"));
|
10
|
+
|
11
|
+
var _utils = require("../utils");
|
12
|
+
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
|
+
|
15
|
+
const cwd = process.cwd();
|
16
|
+
|
17
|
+
const src = _path.default.join(cwd, process.argv[2]);
|
18
|
+
|
19
|
+
const dist = _path.default.join(cwd, process.argv[3]);
|
20
|
+
|
21
|
+
const docopy = process.argv[4] === 'true';
|
22
|
+
const {
|
23
|
+
css: {
|
24
|
+
valueReplacer
|
25
|
+
}
|
26
|
+
} = (0, _utils.getOptions)();
|
27
|
+
|
28
|
+
if (!_fs.default.existsSync(dist)) {
|
29
|
+
_fs.default.mkdirSync(dist, {
|
30
|
+
recursive: true
|
31
|
+
});
|
32
|
+
}
|
33
|
+
|
34
|
+
(0, _folderIterator.default)(src, dist, docopy ? false : ['.css'], false, (fromPath, toPath) => {
|
35
|
+
//console.log({ fromPath: fromPath, toPath: toPath });
|
36
|
+
let css = _fs.default.readFileSync(fromPath);
|
37
|
+
|
38
|
+
if (docopy && !fromPath.endsWith('.css')) {
|
39
|
+
//console.log(toPath,'....');
|
40
|
+
_fs.default.writeFileSync(toPath, css);
|
41
|
+
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
|
45
|
+
(0, _postcss.default)([valueReplacer && require('../postcss-plugins/ValueReplacer')(valueReplacer)]).process(css, {
|
46
|
+
from: fromPath,
|
47
|
+
to: toPath
|
48
|
+
}).then(result => {
|
49
|
+
_fs.default.writeFile(toPath, result.css, () => true);
|
50
|
+
|
51
|
+
if (result.map) {
|
52
|
+
_fs.default.writeFile(`${toPath}.map`, result.map, () => true);
|
53
|
+
}
|
54
|
+
});
|
55
|
+
});
|
@@ -1,5 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
var _fs = require("fs");
|
4
|
+
|
3
5
|
var _path = _interopRequireDefault(require("path"));
|
4
6
|
|
5
7
|
var _libAlias = require("./libAlias");
|
@@ -13,6 +15,9 @@ let moduleNameMapper = Object.keys(_libAlias.libAlias).reduce((previousValue, ke
|
|
13
15
|
previousValue[`^${key}(.*)$`] = `${_libAlias.libAlias[key]}$1`;
|
14
16
|
return previousValue;
|
15
17
|
}, {});
|
18
|
+
|
19
|
+
const appGlobals = _path.default.resolve(appPath, '__testUtils__', 'globals.js');
|
20
|
+
|
16
21
|
let commonConfig = {
|
17
22
|
coverageReporters: ['json', 'html', 'json-summary', 'text'],
|
18
23
|
collectCoverage: true,
|
@@ -28,7 +33,7 @@ let commonConfig = {
|
|
28
33
|
transformIgnorePatterns: ['/node_modules/(?!(@zohodesk)/)'],
|
29
34
|
// transformIgnorePatterns: ['/node_modules.*?.js$'],
|
30
35
|
moduleFileExtensions: ['js'],
|
31
|
-
setupFiles: [
|
36
|
+
setupFiles: [(0, _fs.existsSync)(appGlobals) && appGlobals, _path.default.resolve(__dirname, '..', 'jest', 'setup.js')].filter(Boolean),
|
32
37
|
globals: {
|
33
38
|
__DEVELOPMENT__: true,
|
34
39
|
__DOCS__: false,
|
@@ -8,6 +8,8 @@ var _pluginUtils = require("../pluginUtils");
|
|
8
8
|
|
9
9
|
var _loaderUtils = require("../loaderUtils");
|
10
10
|
|
11
|
+
var _libAlias = require("./libAlias");
|
12
|
+
|
11
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
12
14
|
|
13
15
|
let options = (0, _utils.getOptions)();
|
@@ -21,46 +23,47 @@ let {
|
|
21
23
|
classNamePrefix
|
22
24
|
},
|
23
25
|
app: {
|
24
|
-
folder
|
26
|
+
folder,
|
27
|
+
disableES5Transpile
|
25
28
|
}
|
26
29
|
} = options;
|
27
30
|
let appPath = process.cwd();
|
28
31
|
|
29
32
|
module.exports = isSSTest => ({
|
30
33
|
entry: {
|
31
|
-
main: [_path.default.resolve(__dirname,
|
32
|
-
vendor: [
|
34
|
+
main: [_path.default.resolve(__dirname, '..', 'hooks', 'docsProptypeHook.js'), _path.default.join(appPath, componentFolder, 'index.js')],
|
35
|
+
vendor: ['react', 'react-dom', 'redux', 'react-redux']
|
33
36
|
},
|
34
|
-
devtool:
|
35
|
-
mode:
|
37
|
+
devtool: 'none',
|
38
|
+
mode: 'development',
|
36
39
|
output: {
|
37
|
-
path: _path.default.join(appPath,
|
38
|
-
filename:
|
39
|
-
publicPath:
|
40
|
-
library:
|
41
|
-
libraryTarget:
|
40
|
+
path: _path.default.join(appPath, 'build'),
|
41
|
+
filename: 'js/[name].js',
|
42
|
+
publicPath: '/docs/',
|
43
|
+
library: 'Component',
|
44
|
+
libraryTarget: 'umd'
|
42
45
|
},
|
43
46
|
plugins: (0, _pluginUtils.getDocsPlugins)(isSSTest, options),
|
44
47
|
module: {
|
45
48
|
rules: [{
|
46
49
|
test: /\.js$/,
|
47
50
|
use: [{
|
48
|
-
loader:
|
51
|
+
loader: 'babel-loader',
|
49
52
|
options: {
|
50
|
-
presets: [[require.resolve(
|
53
|
+
presets: [[require.resolve('@babel/preset-env'), {
|
51
54
|
modules: false
|
52
|
-
}], require.resolve(
|
53
|
-
plugins: [[require.resolve(
|
55
|
+
}], require.resolve('@babel/preset-react')],
|
56
|
+
plugins: [[require.resolve('@babel/plugin-transform-runtime'), {
|
54
57
|
helpers: true,
|
55
58
|
regenerator: false
|
56
|
-
}], require.resolve(
|
59
|
+
}], require.resolve('@babel/plugin-syntax-dynamic-import'), require.resolve('@babel/plugin-syntax-object-rest-spread')],
|
57
60
|
cacheDirectory: true
|
58
61
|
}
|
59
62
|
}],
|
60
63
|
include: _path.default.join(appPath, folder)
|
61
64
|
}, {
|
62
65
|
test: /\.docs\.js$/,
|
63
|
-
use: require.resolve(
|
66
|
+
use: require.resolve('../loaders/docsLoader.js'),
|
64
67
|
include: _path.default.join(appPath, folder),
|
65
68
|
exclude: /node_modules/
|
66
69
|
}, {
|
@@ -68,29 +71,29 @@ module.exports = isSSTest => ({
|
|
68
71
|
use: (0, _loaderUtils.getCSSLoaders)(hasRTL, rtlExclude, false, cssUniqueness, null, cssHashSelectors, classNamePrefix)
|
69
72
|
}, {
|
70
73
|
test: /\.jpe?g$|\.gif$|\.png$/,
|
71
|
-
use: [
|
74
|
+
use: ['url-loader?limit=1000&name=./images/[name].[ext]']
|
72
75
|
}, {
|
73
76
|
test: /\.woff2|\.woff$|\.ttf$|\.eot$/,
|
74
|
-
use: [
|
77
|
+
use: ['url-loader?limit=1000&name=./fonts/[name].[ext]']
|
75
78
|
}, {
|
76
79
|
test: /\.svg$/,
|
77
|
-
use: [
|
80
|
+
use: ['url-loader?limit=1&name=./fonts/[name].[ext]']
|
78
81
|
}, {
|
79
82
|
test: /\.html$/,
|
80
83
|
use: {
|
81
|
-
loader:
|
84
|
+
loader: 'html-loader',
|
82
85
|
options: {
|
83
|
-
attrs: [
|
84
|
-
interpolate:
|
86
|
+
attrs: [':data-src'],
|
87
|
+
interpolate: 'require'
|
85
88
|
}
|
86
89
|
}
|
87
90
|
}, {
|
88
91
|
test: /\.ogg$/,
|
89
|
-
use: [
|
92
|
+
use: ['file-loader?name=./fonts/[name].[ext]']
|
90
93
|
}, {
|
91
94
|
test: /\.tmpl$/,
|
92
95
|
use: [{
|
93
|
-
loader:
|
96
|
+
loader: 'html-loader',
|
94
97
|
options: {
|
95
98
|
minimize: {
|
96
99
|
removeComments: true,
|
@@ -104,12 +107,13 @@ module.exports = isSSTest => ({
|
|
104
107
|
}]
|
105
108
|
},
|
106
109
|
externals: {
|
107
|
-
ZC:
|
110
|
+
ZC: '$ZC'
|
108
111
|
},
|
109
112
|
resolve: {
|
110
|
-
modules: [_path.default.resolve(__dirname,
|
113
|
+
modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
|
114
|
+
alias: disableES5Transpile ? _libAlias.libAlias : {}
|
111
115
|
},
|
112
116
|
resolveLoader: {
|
113
|
-
modules: [_path.default.resolve(__dirname,
|
117
|
+
modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
|
114
118
|
}
|
115
119
|
});
|
@@ -20,6 +20,9 @@ let getCSSLoaders = (hasRTL, rtlExclude, classNameBlob, cssUniqueness, selectorR
|
|
20
20
|
const {
|
21
21
|
devCssFileBountry
|
22
22
|
} = options.app;
|
23
|
+
const {
|
24
|
+
valueReplacer
|
25
|
+
} = options.css;
|
23
26
|
const {
|
24
27
|
cssSelectorZipPath
|
25
28
|
} = options.impactService;
|
@@ -36,6 +39,18 @@ let getCSSLoaders = (hasRTL, rtlExclude, classNameBlob, cssUniqueness, selectorR
|
|
36
39
|
cssLoaderOptions.modules.getLocalIdent = (0, _cssClassNameGenerate.default)(cssUniqueness, cssHashSelectors, classNamePrefix);
|
37
40
|
}
|
38
41
|
|
42
|
+
const postcssPlugins = [valueReplacer && require('../postcss-plugins/ValueReplacer')(valueReplacer), selectorReplace && require('postcss-selector-replace')(selectorReplace), hasRTL && require('../postcss-plugins/ExcludeRTLPlugin')({
|
43
|
+
ignore: rtlExcludeLocal,
|
44
|
+
plugins: [require('@zohodesk/postcss-rtl')({
|
45
|
+
addPrefixToSelector: function addPrefixToSelector(selector, prefix) {
|
46
|
+
if (prefix === '[dir]') {
|
47
|
+
return selector;
|
48
|
+
}
|
49
|
+
|
50
|
+
return `${prefix} ${selector}`; // Make selectors like [dir=rtl] > .selector
|
51
|
+
}
|
52
|
+
})]
|
53
|
+
})].filter(Boolean);
|
39
54
|
return [cssSelectorZipPath && {
|
40
55
|
loader: require.resolve('../loaders/selectorMappingLoader')
|
41
56
|
}, {
|
@@ -51,23 +66,12 @@ let getCSSLoaders = (hasRTL, rtlExclude, classNameBlob, cssUniqueness, selectorR
|
|
51
66
|
options: {
|
52
67
|
devCssFileBountry
|
53
68
|
}
|
54
|
-
},
|
69
|
+
}, postcssPlugins.length > 0 ? {
|
55
70
|
loader: 'postcss-loader',
|
56
71
|
options: {
|
57
72
|
ident: 'postcss',
|
58
73
|
plugins: function () {
|
59
|
-
return
|
60
|
-
ignore: rtlExcludeLocal,
|
61
|
-
plugins: [require('@zohodesk/postcss-rtl')({
|
62
|
-
addPrefixToSelector: function addPrefixToSelector(selector, prefix) {
|
63
|
-
if (prefix === '[dir]') {
|
64
|
-
return selector;
|
65
|
-
}
|
66
|
-
|
67
|
-
return `${prefix} ${selector}`; // Make selectors like [dir=rtl] > .selector
|
68
|
-
}
|
69
|
-
})]
|
70
|
-
})].filter(Boolean);
|
74
|
+
return postcssPlugins;
|
71
75
|
}
|
72
76
|
}
|
73
77
|
} : null].filter(Boolean);
|
@@ -0,0 +1,46 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _postcss = _interopRequireDefault(require("postcss"));
|
4
|
+
|
5
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6
|
+
|
7
|
+
// module.exports = postcss.plugin('postcss-value-replacer', opts => {
|
8
|
+
// const { plugins } = opts;
|
9
|
+
// return (root, result) => {
|
10
|
+
// const inputFile = root.source.input.file;
|
11
|
+
// let isIgnoredFile= opts.ignore.some(file => inputFile.indexOf(file)!==-1);
|
12
|
+
// if (!isIgnoredFile) {
|
13
|
+
// const handler = response =>
|
14
|
+
// response.messages.forEach(msg => result.messages.push(msg));
|
15
|
+
// return postcss(plugins)
|
16
|
+
// .process(root, { from: undefined })
|
17
|
+
// .then(handler);
|
18
|
+
// }
|
19
|
+
// };
|
20
|
+
// });
|
21
|
+
// export default
|
22
|
+
module.exports = _postcss.default.plugin('postcss-value-replacer', (valueReplacer = {}) => // Work with options here
|
23
|
+
root => {
|
24
|
+
root.walkDecls(decl => {
|
25
|
+
valueReplacer.forEach(obj => {
|
26
|
+
if (obj.props.indexOf(decl.prop) !== -1) {
|
27
|
+
let ks = Object.keys(obj.values).sort((a, b) => b.length - a.length);
|
28
|
+
ks.forEach(k => {
|
29
|
+
decl.value = decl.value.replace(k, obj.values[k]);
|
30
|
+
}); //decl.value = obj.values[decl.value];
|
31
|
+
}
|
32
|
+
}); //console.log({root, roots:root+""}, root+"")
|
33
|
+
// Transform CSS AST here
|
34
|
+
}); // root.walkDecls(decl => {
|
35
|
+
// valueReplacer.forEach(obj => {
|
36
|
+
// if (
|
37
|
+
// obj.props.indexOf(decl.prop) !== -1 &&
|
38
|
+
// obj.values[decl.value] !== undefined
|
39
|
+
// ) {
|
40
|
+
// decl.value = obj.values[decl.value];
|
41
|
+
// }
|
42
|
+
// });
|
43
|
+
// //console.log({root, roots:root+""}, root+"")
|
44
|
+
// // Transform CSS AST here
|
45
|
+
// });
|
46
|
+
});
|
package/lib/schemas/index.js
CHANGED
@@ -44,6 +44,17 @@ var _default = {
|
|
44
44
|
},
|
45
45
|
css: {
|
46
46
|
enableRTLSplit: false,
|
47
|
+
valueReplacer: null,
|
48
|
+
//valueReplacer: [
|
49
|
+
// {
|
50
|
+
// props: ['font', 'font-family'],
|
51
|
+
// values: {
|
52
|
+
// 'zdfonts-rCallBar': 'zdfonts-rCallBar01',
|
53
|
+
// 'zdfonts-rCall': 'zdfonts-rCallBar02'
|
54
|
+
// }
|
55
|
+
// // ,suffix: '0'
|
56
|
+
// }
|
57
|
+
// ],
|
47
58
|
templateLabel: '{{--dir}}',
|
48
59
|
disableMiniFiySelector: false,
|
49
60
|
dirVarName: 'document.dir'
|
@@ -0,0 +1,98 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.getPaths = getPaths;
|
7
|
+
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
9
|
+
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
11
|
+
|
12
|
+
var _child_process = require("child_process");
|
13
|
+
|
14
|
+
var _utils = require("../utils");
|
15
|
+
|
16
|
+
var _getCliPath = require("./getCliPath");
|
17
|
+
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
|
+
|
20
|
+
const options = (0, _utils.getOptions)(); // const args = process.argv.slice(3);
|
21
|
+
|
22
|
+
const {
|
23
|
+
app: {
|
24
|
+
outputFolder
|
25
|
+
}
|
26
|
+
} = options;
|
27
|
+
const {
|
28
|
+
cssSelectorZipPath
|
29
|
+
} = options.impactService;
|
30
|
+
const zipname = cssSelectorZipPath ? _path.default.parse(cssSelectorZipPath).name : null;
|
31
|
+
|
32
|
+
const outputFolderLocation = _path.default.join(process.cwd(), outputFolder);
|
33
|
+
|
34
|
+
function execSyncDefalut(command) {
|
35
|
+
console.log(' command running ==>', command);
|
36
|
+
return (0, _child_process.execSync)(command, {
|
37
|
+
stdio: 'inherit'
|
38
|
+
});
|
39
|
+
}
|
40
|
+
|
41
|
+
const isQuiet = 'q';
|
42
|
+
const webpack = (0, _getCliPath.getCliPath)('webpack'); // console.log('webpack === > ', webpack, fs.existsSync(webpack));
|
43
|
+
|
44
|
+
if (_fs.default.existsSync(outputFolderLocation)) {
|
45
|
+
execSyncDefalut(`rm -rf ${outputFolder}`);
|
46
|
+
console.log(`previous ${outputFolder} removed`);
|
47
|
+
}
|
48
|
+
|
49
|
+
if (_fs.default.existsSync(_path.default.join(process.cwd(), 'build.zip'))) {
|
50
|
+
execSyncDefalut('rm build.zip');
|
51
|
+
console.log('previous build.zip removed');
|
52
|
+
} // execSyncDefalut(`${webpack } --version`);
|
53
|
+
// execSyncDefalut(`${webpack} --config ${require.resolve('../configs/webpack.dev.config.js')}`);
|
54
|
+
|
55
|
+
|
56
|
+
console.log('webpack compilation starts...');
|
57
|
+
const startTime = Date.now(); // const result = spawnSync(
|
58
|
+
// webpack,
|
59
|
+
// ['--config', require.resolve('../configs/webpack.dev.config.js')].concat(
|
60
|
+
// args
|
61
|
+
// ),
|
62
|
+
// { stdio: 'inherit' }
|
63
|
+
// );
|
64
|
+
|
65
|
+
const result = execSyncDefalut(`${webpack} --config ${require.resolve('../configs/webpack.dev.config.js')}`);
|
66
|
+
result && console.log(result);
|
67
|
+
|
68
|
+
if (result && result.stderr) {
|
69
|
+
throw result.stderr;
|
70
|
+
}
|
71
|
+
|
72
|
+
console.log(`compailation done in ${Date.now() - startTime}ms`);
|
73
|
+
|
74
|
+
if (zipname) {
|
75
|
+
execSyncDefalut(`zip -r${isQuiet} build.zip ${outputFolder}/*`);
|
76
|
+
console.log('build.zip file created');
|
77
|
+
const result = execSyncDefalut(`zip -r${isQuiet} ${cssSelectorZipPath} ${zipname}/*`);
|
78
|
+
execSyncDefalut(`rm -rf ${zipname}`);
|
79
|
+
|
80
|
+
if (result && result.stderr) {
|
81
|
+
console.log('zip file not created', cssSelectorZipPath);
|
82
|
+
console.error(result.stderr);
|
83
|
+
} else {
|
84
|
+
console.log('zip file created', cssSelectorZipPath);
|
85
|
+
}
|
86
|
+
} // npm run start --app:domain=tsi --impact:cssbountry="{$@&&@$}" --disable-watch --dev-cache --cssselector_zip=css-source-map.zip
|
87
|
+
// npm run start --app_domain=tsi --impact_cssbountry="{$@&&@$}" --disable-watch --dev-cache --cssselector_zip=css-source-map.zip
|
88
|
+
|
89
|
+
|
90
|
+
console.log(`compailation done in ${Date.now() - startTime}ms`);
|
91
|
+
|
92
|
+
function getPaths() {
|
93
|
+
return {
|
94
|
+
zipname,
|
95
|
+
cssSelectorZipPath,
|
96
|
+
outputFolderLocation
|
97
|
+
};
|
98
|
+
}
|