@zohodesk/react-cli 1.1.14-kubernetes → 1.1.15
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/.vscode/settings.json +25 -0
- package/README.md +294 -16
- package/bin/cli.js +30 -55
- package/docs/ComposeMinification.md +13 -0
- package/docs/CustomChunks.md +12 -9
- package/docs/MarkdownParser.md +18 -0
- package/docs/ReactLive.md +14 -0
- package/docs/SelectorWeight.md +3 -0
- package/docs/ValueReplacer.md +27 -0
- package/docs/VariableConversion.md +6 -1
- package/docs/patternFiltering.md +57 -0
- package/lib/common/buildEs.js +12 -0
- package/lib/common/runPreProcess.js +71 -0
- package/lib/common/splitChunks.js +65 -45
- package/lib/common/testPattern.js +9 -11
- package/lib/common/valueReplacer.js +1 -3
- package/lib/configs/resolvers.js +16 -5
- package/lib/configs/webpack.css.umd.config.js +3 -2
- package/lib/configs/webpack.dev.config.js +15 -5
- package/lib/configs/webpack.docs.config.js +17 -5
- package/lib/configs/webpack.impact.config.js +11 -4
- package/lib/configs/webpack.prod.config.js +15 -5
- package/lib/constants.js +3 -3
- package/lib/deprecationLogger.js +40 -0
- package/lib/loaderUtils/getCSSLoaders.js +98 -49
- package/lib/loaderUtils/tests/windowsModification.test.js +10 -0
- package/lib/loaderUtils/windowsModification.js +6 -1
- package/lib/loaders/__test__/markdownLoader.spec.js +145 -0
- package/lib/loaders/composeLoader.js +298 -0
- package/lib/loaders/docsLoader.js +18 -7
- package/lib/loaders/markdownLoader.js +71 -0
- package/lib/loaders/reactLiveConvertor.js +105 -0
- package/lib/loaders/selectorMappingLoader.js +9 -9
- package/lib/logger.js +27 -0
- package/lib/pluginUtils/getDevPlugins.js +25 -6
- package/lib/pluginUtils/getProdPlugins.js +32 -5
- package/lib/pluginUtils/getUMDCSSPlugins.js +1 -1
- package/lib/pluginUtils/getUMDComponentPlugins.js +1 -1
- package/lib/plugins/CustomAttributePlugin.js +82 -0
- package/lib/plugins/CustomAttributePlugin.md +35 -0
- package/lib/plugins/EFCPlugin.js +9 -9
- package/lib/plugins/EFCTemplatePlugin.js +10 -12
- package/lib/plugins/EfcResourceCleanupPlugin.js +43 -0
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +8 -9
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +2 -3
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +2 -7
- package/lib/plugins/I18nSplitPlugin/index.js +1 -1
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +8 -8
- package/lib/plugins/{UglifyCSSPlugin.js → MinifyPlugin.js} +3 -3
- package/lib/plugins/ReportGeneratePlugin.js +8 -6
- package/lib/plugins/ResourceHintsPlugin.js +13 -3
- package/lib/plugins/SelectorPlugin.js +77 -37
- package/lib/plugins/StatsPlugin.js +82 -0
- package/lib/plugins/UnusedFilesFindPlugin.js +7 -5
- package/lib/plugins/VariableConversionCollector.js +40 -101
- package/lib/plugins/index.js +7 -7
- package/lib/plugins/utils/classHandling.js +35 -0
- package/lib/plugins/utils/fileHandling.js +92 -0
- package/lib/plugins/utils/tests/fileHandling.test.js +30 -0
- package/lib/plugins/variableConvertorUtils.js +133 -0
- package/lib/postcss-plugins/EmptyPlugin.js +8 -0
- package/lib/postcss-plugins/ExcludePlugin.js +1 -1
- package/lib/postcss-plugins/IncludePlugin.js +23 -0
- package/lib/postcss-plugins/RTLSplitPlugin.js +4 -10
- package/lib/postcss-plugins/SelectorReplace.js +80 -0
- package/lib/postcss-plugins/ValueReplacer.js +8 -29
- package/lib/postcss-plugins/__test__/selectorReplace.test.js +28 -0
- package/lib/postcss-plugins/__test__/valueReplacer.spec.js +43 -0
- package/lib/postcss-plugins/hoverActivePlugin.js +0 -6
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +0 -1
- package/lib/postcss-plugins/variableModificationPlugin/index.js +94 -38
- package/lib/schemas/index.js +95 -18
- package/lib/servers/devBuild.js +13 -11
- package/lib/servers/getCliPath.js +3 -5
- package/lib/servers/httpsOptions.js +12 -13
- package/lib/servers/nowatchserver.js +62 -55
- package/lib/servers/requireLocalOrGlobal.js +61 -0
- package/lib/servers/server.js +53 -52
- package/lib/utils/cssClassNameGenerate.js +70 -13
- package/lib/utils/deprecationSupport.js +134 -0
- package/lib/utils/getOptions.js +35 -28
- package/lib/utils/getServerURL.js +1 -9
- package/lib/utils/index.js +14 -12
- package/lib/utils/initPreCommitHook.js +5 -5
- package/lib/utils/log.js +11 -0
- package/lib/utils/object-manipulation.js +88 -0
- package/lib/utils/pullOrigin.js +3 -3
- package/lib/utils/reinstallDependencies.js +3 -3
- package/lib/utils/selectorReplacer.js +47 -0
- package/lib/utils/switchBranch.js +4 -2
- package/lib/utils/variableConverter.js +104 -0
- package/npm-shrinkwrap.json +33485 -0
- package/package.json +5 -3
- package/templates/docs/all.html +1 -0
- package/templates/docs/component.html +1 -0
- package/templates/docs/components.html +1 -0
- package/templates/docs/css/markdown.css +202 -0
- package/templates/docs/css/style.css +136 -169
- package/templates/docs/index.html +796 -632
- package/lib/plugins/composeCommonPlugin.js +0 -30
- package/lib/postcss-plugins/variableModifier.js +0 -244
|
@@ -16,6 +16,8 @@ var _httpsOptions = require("./httpsOptions");
|
|
|
16
16
|
|
|
17
17
|
var _devBuild = require("./devBuild");
|
|
18
18
|
|
|
19
|
+
var _logger = require("../logger");
|
|
20
|
+
|
|
19
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
22
|
|
|
21
23
|
// import webpack from 'webpack';
|
|
@@ -86,38 +88,41 @@ app.use('/wms/*', (req, res) => {
|
|
|
86
88
|
|
|
87
89
|
const httpsServer = _https.default.createServer(httpsOptions, app);
|
|
88
90
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
let wsPool = [];
|
|
93
|
-
wss.on('connection', ws => {
|
|
94
|
-
wsPool.push(ws);
|
|
95
|
-
ws.on('close', () => {
|
|
96
|
-
wsPool = wsPool.filter(ws1 => ws1 !== ws);
|
|
91
|
+
if (httpsOptions) {
|
|
92
|
+
const wss = new _ws.default.Server({
|
|
93
|
+
server: httpsServer
|
|
97
94
|
});
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
let wsPool = [];
|
|
96
|
+
wss.on('connection', ws => {
|
|
97
|
+
wsPool.push(ws);
|
|
98
|
+
ws.on('close', () => {
|
|
99
|
+
wsPool = wsPool.filter(ws1 => ws1 !== ws);
|
|
100
|
+
});
|
|
101
|
+
ws.on('message', message => {
|
|
102
|
+
(0, _utils.log)('received: %s', message);
|
|
103
|
+
});
|
|
104
|
+
ws.send('something');
|
|
100
105
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
app.post('/wmsmockapi', (req, res) => {
|
|
107
|
+
wsPool.forEach(ws => {
|
|
108
|
+
const {
|
|
109
|
+
body
|
|
110
|
+
} = req;
|
|
111
|
+
|
|
112
|
+
try {
|
|
113
|
+
ws.send(JSON.stringify(body));
|
|
114
|
+
} catch (e) {
|
|
115
|
+
(0, _utils.log)(e, body);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
res.send('success');
|
|
114
119
|
});
|
|
115
|
-
|
|
116
|
-
}); // let webpackCompilation;
|
|
120
|
+
} // let webpackCompilation;
|
|
117
121
|
// compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
|
|
118
122
|
// webpackCompilation = compilation;
|
|
119
123
|
// });
|
|
120
124
|
|
|
125
|
+
|
|
121
126
|
if (zipname) {
|
|
122
127
|
app.use(`/zips/${zipname}.zip`, (req, res) => {
|
|
123
128
|
res.download(_path.default.join(process.cwd(), cssSelectorZipPath), err => {
|
|
@@ -125,7 +130,7 @@ if (zipname) {
|
|
|
125
130
|
throw err;
|
|
126
131
|
}
|
|
127
132
|
|
|
128
|
-
|
|
133
|
+
(0, _logger.messageLogger)(`${zipname}.zip downloaded`);
|
|
129
134
|
});
|
|
130
135
|
});
|
|
131
136
|
app.use('/zips/build.zip', (req, res) => {
|
|
@@ -134,7 +139,7 @@ if (zipname) {
|
|
|
134
139
|
throw err;
|
|
135
140
|
}
|
|
136
141
|
|
|
137
|
-
|
|
142
|
+
(0, _logger.messageLogger)('build.zip downloaded');
|
|
138
143
|
});
|
|
139
144
|
});
|
|
140
145
|
}
|
|
@@ -151,40 +156,42 @@ if (contextURL) {
|
|
|
151
156
|
app.use('/*', _express.default.static(context));
|
|
152
157
|
}
|
|
153
158
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
159
|
+
if (httpsOptions) {
|
|
160
|
+
httpsServer.listen(port, err => {
|
|
161
|
+
if (err) {
|
|
162
|
+
throw err;
|
|
163
|
+
}
|
|
158
164
|
|
|
159
|
-
|
|
160
|
-
});
|
|
165
|
+
(0, _utils.log)(`Listening at ${serverUrl}${contextURL}/`);
|
|
166
|
+
});
|
|
161
167
|
|
|
162
|
-
if (isCompatableHttp2) {
|
|
163
|
-
|
|
168
|
+
if (isCompatableHttp2) {
|
|
169
|
+
const http2 = require('http2');
|
|
164
170
|
|
|
165
|
-
|
|
171
|
+
const http2Server = http2.createSecureServer(httpsOptions); // eslint-disable-next-line no-unused-vars
|
|
166
172
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
173
|
+
http2Server.on('stream', (stream, headers) => {
|
|
174
|
+
stream.respond({
|
|
175
|
+
'content-type': 'text/html',
|
|
176
|
+
':status': 200
|
|
177
|
+
});
|
|
178
|
+
stream.end('<h1>Hello World! <br>Working with http2</h1>');
|
|
171
179
|
});
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
throw err;
|
|
178
|
-
}
|
|
180
|
+
const http2Port = Number(port) + 1;
|
|
181
|
+
http2Server.listen(http2Port, err => {
|
|
182
|
+
if (err) {
|
|
183
|
+
throw err;
|
|
184
|
+
}
|
|
179
185
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
} else {
|
|
187
|
-
|
|
186
|
+
(0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
|
|
187
|
+
host,
|
|
188
|
+
domain,
|
|
189
|
+
port: http2Port
|
|
190
|
+
}, 'htt' + 'ps')}${contextURL}/`, 'http2 server');
|
|
191
|
+
});
|
|
192
|
+
} else {
|
|
193
|
+
(0, _utils.log)('Your node version didn\'t adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2');
|
|
194
|
+
}
|
|
188
195
|
}
|
|
189
196
|
|
|
190
197
|
const httpPort = Number(port) + (isCompatableHttp2 ? 2 : 1);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.globalNodeModules = void 0;
|
|
7
|
+
exports.requireGlobal = requireGlobal;
|
|
8
|
+
exports.requireLocal = requireLocal;
|
|
9
|
+
exports.requireLocalOrGlobal = requireLocalOrGlobal;
|
|
10
|
+
|
|
11
|
+
var _child_process = require("child_process");
|
|
12
|
+
|
|
13
|
+
var _path = _interopRequireDefault(require("path"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
|
|
17
|
+
const globalNodeModules = _path.default.join(`${(0, _child_process.execSync)('npm config get prefix')}`.trim(), 'lib');
|
|
18
|
+
|
|
19
|
+
exports.globalNodeModules = globalNodeModules;
|
|
20
|
+
|
|
21
|
+
function requireLocalOrGlobal(moduleName, opts = {}) {
|
|
22
|
+
let {
|
|
23
|
+
global = true
|
|
24
|
+
} = opts;
|
|
25
|
+
const {
|
|
26
|
+
local = true
|
|
27
|
+
} = opts;
|
|
28
|
+
const isRelativePath = moduleName[0] === '.'; // NOTE: if starts with . then it only mean local
|
|
29
|
+
|
|
30
|
+
if (isRelativePath) {
|
|
31
|
+
global = false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const paths = [local && process.cwd(), global && globalNodeModules].filter(Boolean); // x({ paths, globalNodeModules, global, local, opts });
|
|
36
|
+
|
|
37
|
+
const moduleResolvePath = require.resolve(moduleName, {
|
|
38
|
+
paths
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return require(moduleResolvePath);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
// NOTE: since we return null we can check out side
|
|
44
|
+
// console.log('Re validate: ', error);
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function requireLocal(moduleName) {
|
|
50
|
+
return requireLocalOrGlobal(moduleName, {
|
|
51
|
+
global: false,
|
|
52
|
+
local: true
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function requireGlobal(moduleName) {
|
|
57
|
+
return requireLocalOrGlobal(moduleName, {
|
|
58
|
+
global: true,
|
|
59
|
+
local: false
|
|
60
|
+
});
|
|
61
|
+
}
|
package/lib/servers/server.js
CHANGED
|
@@ -70,8 +70,7 @@ if (mode === 'prod') {
|
|
|
70
70
|
config = require('../configs/webpack.dev.config');
|
|
71
71
|
} else {
|
|
72
72
|
throw new Error('You must configure valid option in mode');
|
|
73
|
-
}
|
|
74
|
-
|
|
73
|
+
}
|
|
75
74
|
|
|
76
75
|
const compiler = (0, _webpack.default)(config);
|
|
77
76
|
const webpackServerOptions = {
|
|
@@ -101,7 +100,6 @@ app.use((0, _HMRMiddleware.default)(compiler, {
|
|
|
101
100
|
path: '/sockjs-node/info'
|
|
102
101
|
}));
|
|
103
102
|
app.use((req, res, next) => {
|
|
104
|
-
//console.log('origin', req.get('origin'));
|
|
105
103
|
res.setHeader('Access-Control-Allow-Origin', req.get('origin') || '*'); // res.setHeader('Access-Control-Allow-Origin', req.get('origin'));
|
|
106
104
|
|
|
107
105
|
res.setHeader('Access-Control-Allow-Private-Network', true);
|
|
@@ -117,34 +115,37 @@ app.use('/wms/*', (req, res) => {
|
|
|
117
115
|
|
|
118
116
|
const httpsServer = _https.default.createServer(httpsOptions, app);
|
|
119
117
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
let wsPool = [];
|
|
124
|
-
wss.on('connection', ws => {
|
|
125
|
-
wsPool.push(ws);
|
|
126
|
-
ws.on('close', () => {
|
|
127
|
-
wsPool = wsPool.filter(ws1 => ws1 !== ws);
|
|
118
|
+
if (httpsOptions) {
|
|
119
|
+
const wss = new _ws.default.Server({
|
|
120
|
+
server: httpsServer
|
|
128
121
|
});
|
|
129
|
-
|
|
130
|
-
|
|
122
|
+
let wsPool = [];
|
|
123
|
+
wss.on('connection', ws => {
|
|
124
|
+
wsPool.push(ws);
|
|
125
|
+
ws.on('close', () => {
|
|
126
|
+
wsPool = wsPool.filter(ws1 => ws1 !== ws);
|
|
127
|
+
});
|
|
128
|
+
ws.on('message', message => {
|
|
129
|
+
(0, _utils.log)('received: %s', message);
|
|
130
|
+
});
|
|
131
|
+
ws.send('something');
|
|
131
132
|
});
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
133
|
+
app.post('/wmsmockapi', (req, res) => {
|
|
134
|
+
wsPool.forEach(ws => {
|
|
135
|
+
const {
|
|
136
|
+
body
|
|
137
|
+
} = req;
|
|
138
|
+
|
|
139
|
+
try {
|
|
140
|
+
ws.send(JSON.stringify(body));
|
|
141
|
+
} catch (e) {
|
|
142
|
+
(0, _utils.log)(e, body);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
res.send('success');
|
|
145
146
|
});
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
}
|
|
148
|
+
|
|
148
149
|
let webpackCompilation;
|
|
149
150
|
let initalHTML;
|
|
150
151
|
compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
|
|
@@ -176,34 +177,34 @@ if (httpsOptions) {
|
|
|
176
177
|
|
|
177
178
|
(0, _utils.log)(`Listening at ${serverUrl}${contextURL}/`);
|
|
178
179
|
});
|
|
179
|
-
}
|
|
180
180
|
|
|
181
|
-
if (isCompatableHttp2
|
|
182
|
-
|
|
181
|
+
if (isCompatableHttp2) {
|
|
182
|
+
const http2 = require('http2');
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
const http2Server = http2.createSecureServer(httpsOptions); // eslint-disable-next-line no-unused-vars
|
|
185
185
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
186
|
+
http2Server.on('stream', (stream, headers) => {
|
|
187
|
+
stream.respond({
|
|
188
|
+
'content-type': 'text/html',
|
|
189
|
+
':status': 200
|
|
190
|
+
});
|
|
191
|
+
stream.end('<h1>Hello World! <br>Working with http2</h1>');
|
|
190
192
|
});
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
(0, _utils.log)('Your node version didn\'t adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2');
|
|
193
|
+
const http2Port = Number(port) + 1;
|
|
194
|
+
http2Server.listen(http2Port, err => {
|
|
195
|
+
if (err) {
|
|
196
|
+
throw err;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
(0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
|
|
200
|
+
host,
|
|
201
|
+
domain,
|
|
202
|
+
port: http2Port
|
|
203
|
+
}, 'htt' + 'ps')}${contextURL}/`, 'http2 server');
|
|
204
|
+
});
|
|
205
|
+
} else if (httpsOptions) {
|
|
206
|
+
(0, _utils.log)('Your node version didn\'t adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2');
|
|
207
|
+
}
|
|
207
208
|
}
|
|
208
209
|
|
|
209
210
|
const httpPort = Number(port) + (isCompatableHttp2 ? 2 : 1);
|
|
@@ -9,13 +9,15 @@ var _os = _interopRequireDefault(require("os"));
|
|
|
9
9
|
|
|
10
10
|
var _path = _interopRequireDefault(require("path"));
|
|
11
11
|
|
|
12
|
+
var _fileHandling = require("../plugins/utils/fileHandling");
|
|
13
|
+
|
|
12
14
|
var _getHash = _interopRequireDefault(require("./getHash"));
|
|
13
15
|
|
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
const isWindows = _os.default.platform().toLowerCase() === 'win32';
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
const isSelectorPackage = (resourcePath, packages) => {
|
|
19
21
|
if (!resourcePath.includes('node_modules')) {
|
|
20
22
|
return false;
|
|
21
23
|
}
|
|
@@ -36,38 +38,93 @@ let isSelectorPackage = (resourcePath, packages) => {
|
|
|
36
38
|
return isValid;
|
|
37
39
|
};
|
|
38
40
|
|
|
41
|
+
function patternBasedClass({
|
|
42
|
+
customClassNamePrefix,
|
|
43
|
+
context,
|
|
44
|
+
relativePath,
|
|
45
|
+
localName
|
|
46
|
+
}) {
|
|
47
|
+
let newName = null;
|
|
48
|
+
customClassNamePrefix.forEach(obj => {
|
|
49
|
+
if (obj.enable) {
|
|
50
|
+
if (obj.patterns && obj.prefix && (0, _fileHandling.isFileNameMatchingPluginPattern)({
|
|
51
|
+
filename: context.resourcePath,
|
|
52
|
+
filterArr: obj.patterns
|
|
53
|
+
})) {
|
|
54
|
+
const h = (0, _getHash.default)(`${relativePath}-${localName}`, 10);
|
|
55
|
+
newName = `${obj.prefix}${h}`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return newName;
|
|
60
|
+
}
|
|
61
|
+
|
|
39
62
|
var _default = (unique = true, {
|
|
40
63
|
filenames,
|
|
41
64
|
packages
|
|
42
|
-
}, classNamePrefix) => (context, localIdentName, localName) => {
|
|
43
|
-
//
|
|
65
|
+
}, classNamePrefix, customClassNamePrefix, patterns) => (context, localIdentName, localName) => {
|
|
66
|
+
// console.log(patterns, context.resourcePath);
|
|
67
|
+
// NOTE: in build machine we use date as folder path.
|
|
44
68
|
// So every time we create new build there is path will alway different
|
|
45
|
-
// in order to
|
|
69
|
+
// in order to minimize that problem we try in relative path;
|
|
46
70
|
// console.log('context.resourcePath', context.resourcePath, context);
|
|
47
71
|
// let contextResourcePath = context.resourcePath;
|
|
48
|
-
|
|
72
|
+
const filePaths = context.resourcePath.split(_path.default.sep);
|
|
73
|
+
const fileName = filePaths[filePaths.length - 1];
|
|
74
|
+
const [fileNameWithoutExt] = fileName.split('.');
|
|
75
|
+
const cleanFileName = fileNameWithoutExt.replace(/-/g, '_').toLowerCase();
|
|
76
|
+
|
|
77
|
+
const relativePath = _path.default.relative(context.rootContext, context.resourcePath); // console.log('customClassNamePrefix', customClassNamePrefix);
|
|
78
|
+
|
|
79
|
+
/*
|
|
80
|
+
input :
|
|
81
|
+
context.resourcePath : 'D:/MyWork/..../desk_client_app/supportapp/src/components/Avatar/Avatar.module.css,
|
|
82
|
+
|
|
83
|
+
patterns.cssVariableReplacement:
|
|
84
|
+
// include src folder, include deskapp folder, exclude node modules
|
|
85
|
+
"cssUniqueness": [
|
|
86
|
+
"src",
|
|
87
|
+
"deskapp",
|
|
88
|
+
"!node_modules"
|
|
89
|
+
]
|
|
90
|
+
output :
|
|
91
|
+
true or false
|
|
92
|
+
*/
|
|
93
|
+
|
|
49
94
|
|
|
50
95
|
if (context.resourcePath.endsWith('.plain.css')) {
|
|
51
96
|
return localName;
|
|
52
97
|
}
|
|
98
|
+
|
|
99
|
+
if (!(0, _fileHandling.isFileNameMatchingPluginPattern)({
|
|
100
|
+
filename: context.resourcePath,
|
|
101
|
+
filterArr: patterns.cssUniqueness
|
|
102
|
+
})) {
|
|
103
|
+
return `${classNamePrefix}-${cleanFileName}-${localName}`;
|
|
104
|
+
}
|
|
53
105
|
/* old production mode start without breaking so added. may be removed in future*/
|
|
54
106
|
|
|
55
107
|
|
|
56
108
|
if (unique) {
|
|
57
|
-
|
|
109
|
+
const h = (0, _getHash.default)(`${relativePath}-${localName}`, 10);
|
|
58
110
|
return `${classNamePrefix}${h}`;
|
|
59
111
|
}
|
|
60
|
-
/* old production mode end*/
|
|
61
112
|
|
|
113
|
+
const patternClass = patternBasedClass({
|
|
114
|
+
customClassNamePrefix,
|
|
115
|
+
context,
|
|
116
|
+
relativePath,
|
|
117
|
+
localName
|
|
118
|
+
});
|
|
62
119
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
let cleanFileName = fileNameWithoutExt.replace(/-/g, '_').toLowerCase(); //css file has casesensitive selector issue so can't toLowerCase
|
|
120
|
+
if (patternClass) {
|
|
121
|
+
return patternClass;
|
|
122
|
+
} //css file has case sensitive selector issue so can't toLowerCase
|
|
67
123
|
//let local = localName.toLowerCase()
|
|
68
124
|
|
|
125
|
+
|
|
69
126
|
if (isSelectorPackage(context.resourcePath, packages) || filenames.indexOf(cleanFileName) !== -1) {
|
|
70
|
-
|
|
127
|
+
const h = (0, _getHash.default)(`${relativePath}-${localName}`, 10);
|
|
71
128
|
return `${classNamePrefix}${h}`;
|
|
72
129
|
}
|
|
73
130
|
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.deprecationSupport = deprecationSupport;
|
|
7
|
+
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
|
|
10
|
+
var deprecationHandlers = _interopRequireWildcard(require("../deprecationLogger"));
|
|
11
|
+
|
|
12
|
+
var _windowsModification = require("../loaderUtils/windowsModification");
|
|
13
|
+
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
+
|
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
deprecateMessage,
|
|
22
|
+
deprecateOption,
|
|
23
|
+
deprecationLoggerEnd
|
|
24
|
+
} = deprecationHandlers;
|
|
25
|
+
|
|
26
|
+
function modifyCssArr(arr) {
|
|
27
|
+
return arr.map(x => {
|
|
28
|
+
const includeCss = !x.startsWith('!');
|
|
29
|
+
const modifier = includeCss ? '/*.css' : '';
|
|
30
|
+
const filePath = x.replace(/^!/, ''); // Remove the "!" symbol if present
|
|
31
|
+
|
|
32
|
+
return (0, _windowsModification.windowsModificationFile)(_path.default.join(includeCss ? '**' : '!**', filePath, '**', modifier));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const defaultPostCssPluginOptions = {
|
|
37
|
+
valueReplacer: null,
|
|
38
|
+
hasRTL: false,
|
|
39
|
+
selectorReplace: null,
|
|
40
|
+
hoverActive: false,
|
|
41
|
+
combinerMediaQuery: false,
|
|
42
|
+
cssVariableReplacement: false,
|
|
43
|
+
selectorWeight: false,
|
|
44
|
+
minifier: false,
|
|
45
|
+
composeMinification: false
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
function deprecationSupport(options, disableDeprecationWarning) {
|
|
49
|
+
if (disableDeprecationWarning) {
|
|
50
|
+
/* eslint-disable no-empty-function */
|
|
51
|
+
deprecateMessage = () => {};
|
|
52
|
+
|
|
53
|
+
deprecateOption = () => {};
|
|
54
|
+
|
|
55
|
+
deprecationLoggerEnd = () => {};
|
|
56
|
+
/* eslint-enable no-empty-function */
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
options.app.plugins = options.app.plugins || defaultPostCssPluginOptions;
|
|
61
|
+
options.docs.plugins = options.docs.plugins || defaultPostCssPluginOptions;
|
|
62
|
+
options.css.plugins = options.css.plugins || defaultPostCssPluginOptions; // if (selectn(options, ".app.hasRTL") === true) {
|
|
63
|
+
|
|
64
|
+
if (options.app.hasRTL === true) {
|
|
65
|
+
deprecateOption('app.hasRTL', 'app.plugins.hasRTL');
|
|
66
|
+
options.app.plugins.hasRTL = true;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (options.docs.hasRTL === true) {
|
|
70
|
+
deprecateOption('docs.hasRTL', 'docs.plugins.hasRTL');
|
|
71
|
+
options.docs.plugins.hasRTL = true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (options.app.selectorReplace !== null && options.app.plugins && (options.app.plugins.selectorReplace === null || options.app.plugins.selectorReplace === undefined)) {
|
|
75
|
+
deprecateMessage('when you use app.selectorReplace mention enable or disable app.plugins.selectorReplace by setting value to true or false');
|
|
76
|
+
options.app.plugins.selectorReplace = true;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (options.docs.selectorReplace !== null && options.docs.plugins && (options.docs.plugins.selectorReplace === null || options.docs.plugins.selectorReplace === undefined)) {
|
|
80
|
+
deprecateMessage('when you use docs.selectorReplace mention enable or disable docs.plugins.selectorReplace by setting value to true or false');
|
|
81
|
+
options.docs.plugins.selectorReplace = true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (options.css.valueReplacer !== null && options.css.plugins && (options.app.plugins.valueReplacer === null || options.app.plugins.valueReplacer === undefined)) {
|
|
85
|
+
deprecateMessage('when you use app.valueReplacer mention enable or disable app.plugins.valueReplacer by setting value to true or false');
|
|
86
|
+
options.app.plugins.valueReplacer = true;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (!options.app.patterns) {
|
|
90
|
+
options.app.patterns = {};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function handleRTL(rtlExclude, rtl, hasRTL, type) {
|
|
94
|
+
if (rtlExclude && rtlExclude.length > 0) {
|
|
95
|
+
options[type].patterns.hasRTL = modifyCssArr(rtlExclude);
|
|
96
|
+
deprecateOption(`${type}.rtlExclude`, `${type}.patterns.hasRTL`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (rtl && rtl.length > 0) {
|
|
100
|
+
options[type].patterns.hasRTL = modifyCssArr(rtl);
|
|
101
|
+
deprecateOption(`${type}.exclude.rtl`, `${type}.patterns.hasRTL`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (hasRTL && hasRTL.length > 0) {
|
|
105
|
+
options[type].patterns.hasRTL = modifyCssArr(hasRTL);
|
|
106
|
+
deprecateOption(`${type}.exclude.hasRTL`, `${type}.patterns.hasRTL`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function addExcludesToPattern(patterns, exclude, type) {
|
|
111
|
+
Object.keys(defaultPostCssPluginOptions).forEach(key => {
|
|
112
|
+
if (!exclude[key] || exclude[key].length === 0) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (patterns[key].length === 0) {
|
|
117
|
+
deprecateOption(`${type}.exclude.${key}`, `${type}.patterns.${key}`);
|
|
118
|
+
let tempArr = exclude[key];
|
|
119
|
+
tempArr = tempArr.map(x => _path.default.join('!**', x, '**')); // Since patterns[key] is empty we need to wildcard for allow all others.
|
|
120
|
+
|
|
121
|
+
tempArr.unshift('*');
|
|
122
|
+
patterns[key] = tempArr;
|
|
123
|
+
} else if (exclude[key].length > 0 && patterns[key].length > 0) {
|
|
124
|
+
deprecateOption(`${type}.exclude.${key}`, `${type}.patterns.${key}`, ` And Since you have used ${type}.patterns.${key} we won't use ${type}.exclude.${key}. So please make appropriate changes`);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
handleRTL(options.app.rtlExclude, options.app.exclude.rtl, options.app.exclude.hasRTL, 'app');
|
|
130
|
+
handleRTL(options.docs.rtlExclude, options.docs.exclude.rtl, options.docs.exclude.hasRTL, 'docs');
|
|
131
|
+
addExcludesToPattern(options.app.patterns, options.app.exclude, 'app');
|
|
132
|
+
addExcludesToPattern(options.docs.patterns, options.docs.exclude, 'docs');
|
|
133
|
+
deprecationLoggerEnd();
|
|
134
|
+
}
|