-
Notifications
You must be signed in to change notification settings - Fork 0
/
extension.js
56 lines (42 loc) · 1.14 KB
/
extension.js
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
/* global define, $ */
"use strict";
define(function(require, exports, module) {
const ExtensionManager = require('core/extensionManager');
const Utils = require('core/utils');
const FileManager = require('core/fileManager');
const Autoprefixer = require('./autoprefixer');
const EditorEditors = require('modules/editor/ext/editors');
const EditorCompiler = require('modules/editor/ext/compiler');
class Extension extends ExtensionManager.Extension {
constructor() {
super({
name: 'css-autoprefixer',
});
this.watcher = null;
this.compilerName = 'CSS Autoprefixer';
}
init() {
super.init();
EditorCompiler.addPlugin(this.name, this.onPlugin);
}
destroy() {
super.destroy();
EditorCompiler.removePlugin(this.name);
}
onPlugin(output, cb) {
Autoprefixer.process(output, {
add: false,
browsers: []
}).then(function(cleaned) {
Autoprefixer.process(cleaned.css).then(function(prefixed) {
cb(prefixed.css);
}, function(error) {
cb(null, error);
});
}, function(error) {
cb(null, error);
});
}
}
module.exports = new Extension();
});