mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
* [codeshift] add proper ignore comments * [codeshift] apply require-to-import transform * [codeshift/fixup] remove duplicate imports * [eslint] upgrade config for react "unused" support * [codeshift] apply remove-unused-imports transform * [codeshift] apply remove-unused-basic-requires transform * [codeshift] apply remove-unused-function-arguments transform * [lintroller] fix argument list spacing * [codeshift] apply remove-unused-basic-bars transform * [codeshift/fixup] fixup unused basic var removals * manually apply remove-unused-assignments transform * [codeshift] reapply remove-unused-imports transform * [codeshift] reapply remove-unused-function-arguments transform * [eslint] autofix param spacing * manually fix remaining no-undef errors * use more descriptive file ignore pattern * add eslint-plugin-react peerDependency * replace values that looked unused in tests * remove // kibana-jscodeshift-no-babel comment * remove import statements from code required by api tests * Remove '// kibana-jscodeshift-ignore' comments * address review feedback * remove remnant of removed if condition
78 lines
2.2 KiB
JavaScript
78 lines
2.2 KiB
JavaScript
import sass from 'node-sass';
|
|
import postcss from 'postcss';
|
|
import postcssConfig from '../src/optimize/postcss.config';
|
|
import chokidar from 'chokidar';
|
|
import debounce from 'lodash/function/debounce';
|
|
const platform = require('os').platform();
|
|
|
|
module.exports = function (grunt) {
|
|
grunt.registerTask('uiFramework:start', function () {
|
|
const done = this.async();
|
|
Promise.all([uiFrameworkWatch(), uiFrameworkServerStart()]).then(done);
|
|
});
|
|
|
|
function uiFrameworkServerStart() {
|
|
const serverCmd = {
|
|
cmd: /^win/.test(platform) ? '.\\node_modules\\.bin\\webpack-dev-server.cmd' : './node_modules/.bin/webpack-dev-server',
|
|
args: [
|
|
'--config=ui_framework/doc_site/webpack.config.js',
|
|
'--hot ',
|
|
'--inline',
|
|
'--content-base=ui_framework/doc_site/build',
|
|
'--host=0.0.0.0',
|
|
'--port=8020',
|
|
],
|
|
opts: { stdio: 'inherit' }
|
|
};
|
|
|
|
return new Promise((resolve, reject) => {
|
|
grunt.util.spawn(serverCmd, (error, result, code) => {
|
|
if (error || code !== 0) {
|
|
const message = result.stderr || result.stdout;
|
|
|
|
grunt.log.error(message);
|
|
|
|
return reject();
|
|
}
|
|
|
|
grunt.log.writeln(result);
|
|
|
|
resolve();
|
|
});
|
|
|
|
});
|
|
}
|
|
|
|
function uiFrameworkCompile() {
|
|
sass.render({
|
|
file: 'ui_framework/components/index.scss'
|
|
}, function (error, result) {
|
|
if (error) {
|
|
grunt.log.error(error);
|
|
}
|
|
|
|
postcss([postcssConfig])
|
|
.process(result.css, { from: 'ui_framework/components/index.scss', to: 'ui_framework/dist/ui_framework.css' })
|
|
.then(result => {
|
|
grunt.file.write('ui_framework/dist/ui_framework.css', result.css);
|
|
|
|
if (result.map) {
|
|
grunt.file.write('ui_framework/dist/ui_framework.css.map', result.map);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
function uiFrameworkWatch() {
|
|
const debouncedCompile = debounce(uiFrameworkCompile, 400, { leading: true });
|
|
|
|
return new Promise(() => {
|
|
debouncedCompile();
|
|
|
|
chokidar.watch('ui_framework/components', { ignoreInitial: true }).on('all', (event, path) => {
|
|
grunt.log.writeln(event, path);
|
|
debouncedCompile();
|
|
});
|
|
});
|
|
}
|
|
};
|