forked from pitaj/nodebb-plugin-calendar
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathremoveAMD.js
More file actions
49 lines (40 loc) · 1.3 KB
/
Copy pathremoveAMD.js
File metadata and controls
49 lines (40 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const replaceInFCLang = /!function\(e\)\{.*?moment\)\}/;
const replaceWithFCLang = 'import moment from "moment"; (function (e) { e(jQuery, moment); })';
const fullCalendarLang = text =>
text
.replace(replaceInFCLang, replaceWithFCLang)
.replace(/defineLocale/, 'updateLocale');
const replaceInFC = /\(function\(factory\) \{[\w\W]+\}\)\(function\(\$, moment\) \{/;
const replaceWithFC =
`import moment from "moment";
(function(factory) {
factory(jQuery, moment);
})(function($, moment) {`;
const fullCalendar = text =>
text
.replace(replaceInFC, replaceWithFC);
const replaceInDTP = /\(function \(factory\) \{[\w\W]+\}\(function \(\$, moment\) \{/;
const replaceWithDTP =
`import moment from "moment";
(function (factory) {
factory(jQuery, moment);
}(function ($, moment) {
`;
const dtp = text =>
text
.replace(replaceInDTP, replaceWithDTP);
module.exports = function loader(content) {
if (this.resourcePath.match(/fullcalendar[/\\]+dist[/\\]+locale/)) {
const output = fullCalendarLang(content);
return output;
}
if (this.resourcePath.includes('fullcalendar')) {
const output = fullCalendar(content);
return output;
}
if (this.resourcePath.includes('eonasdan-bootstrap-datetimepicker')) {
const output = dtp(content);
return output;
}
return content;
};