-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathgulpfile.js
More file actions
63 lines (56 loc) · 1.92 KB
/
Copy pathgulpfile.js
File metadata and controls
63 lines (56 loc) · 1.92 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const gulp = require('gulp');
const rename = require('gulp-rename');
const postcss = require('gulp-postcss');
const drupalize = require('./js/postcss/drupalize');
const gulpConfig = {
dist: './js',
main: 'patternkit.jsoneditor.js',
lib: [
'./node_modules/@json-editor/json-editor/dist/**',
'./node_modules/handlebars/dist/handlebars.js',
'./node_modules/handlebars/dist/handlebars.min.js',
],
};
gulp.task('copy:lib', () =>
gulp.src(gulpConfig.lib).pipe(gulp.dest(gulpConfig.dist)),
);
// Prepare processing for prefixing CSS style rules.
const patternkitTargetId = '#patternkit-editor-target';
const drupalModalId = '#drupal-off-canvas-wrapper';
const nonModalSelector = `${patternkitTargetId}:not(${drupalModalId} *)`;
// Prefix to target both inside and outside the sidebar tray.
const prefixPlugin = drupalize({
prefixes: [drupalModalId, nonModalSelector],
});
// Append the CKEditor scope restriction to all rules outside the sidebar tray.
const suffixPlugin = drupalize({
suffixes: [':not(.ck *)'],
filter: patternkitTargetId,
});
// Prefixes upstream JSON Editor's core styles, so they can be used in
// non-shadow DOM version of Cygnet.
gulp.task('prefix-css:cygnet-theme-upstream', () =>
gulp
.src('./node_modules/@json-editor/json-editor/src/style.css')
.pipe(postcss([drupalize({ prefixes: ['[data-theme=cygnet]'] })]))
.pipe(rename('cygnet--prefixed-for-drupal--upstream.css'))
.pipe(gulp.dest('./css/cygnet')),
);
// Prefixes Cygnet's styles, so they work when JSON Editor gets loaded outside
// the shadow DOM.
gulp.task('prefix-css:cygnet-theme', () =>
gulp
.src('./css/cygnet/cygnet.css')
.pipe(rename('cygnet--prefixed-for-drupal.css'))
.pipe(postcss([prefixPlugin]))
.pipe(postcss([suffixPlugin]))
.pipe(gulp.dest('./css/cygnet')),
);
gulp.task(
'default',
gulp.parallel([
'copy:lib',
'prefix-css:cygnet-theme',
'prefix-css:cygnet-theme-upstream',
]),
);