Skip to content

Commit

Permalink
Remove libsass as a dependency (#9803) (#9811)
Browse files Browse the repository at this point in the history
Remove libsass as a dependency

libsass is platform specific, therefore we can not ship it as a dependency. Instead, we will commit the compiled CSS for the UI Framework to the repository. This is updated when running `npm run uiFramework:start` which also starts the docs site.

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
  • Loading branch information
tylersmalley authored Jan 10, 2017
1 parent 0e8daec commit b190867
Show file tree
Hide file tree
Showing 133 changed files with 1,098 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ selenium
*.swp
*.swo
*.out
src/ui_framework/doc_site/build/*.js*
ui_framework/doc_site/build/*.js*
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"mocha": "mocha",
"mocha:debug": "mocha --debug-brk",
"sterilize": "grunt sterilize",
"uiFramework:start": "webpack-dev-server --config src/ui_framework/doc_site/webpack.config.js --hot --inline --content-base src/ui_framework/doc_site/build"
"uiFramework:start": "grunt uiFramework:start"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -144,7 +144,6 @@
"moment-timezone": "0.5.4",
"no-ui-slider": "1.2.0",
"node-fetch": "1.3.2",
"node-sass": "3.8.0",
"node-uuid": "1.4.7",
"pegjs": "0.9.0",
"postcss-loader": "1.2.1",
Expand All @@ -154,7 +153,6 @@
"rimraf": "2.4.3",
"rison-node": "1.0.0",
"rjs-repack-loader": "1.0.6",
"sass-loader": "4.0.0",
"script-loader": "0.6.1",
"semver": "5.1.0",
"style-loader": "0.12.3",
Expand Down Expand Up @@ -220,6 +218,7 @@
"mocha": "2.5.3",
"murmurhash3js": "3.0.1",
"ncp": "2.0.0",
"node-sass": "3.8.0",
"nock": "8.0.0",
"npm": "3.10.8",
"portscanner": "1.0.0",
Expand All @@ -232,6 +231,7 @@
"react-router-redux": "4.0.4",
"redux": "3.0.0",
"redux-thunk": "0.1.0",
"sass-loader": "4.0.0",
"simple-git": "1.37.0",
"sinon": "1.17.2",
"source-map": "0.5.6",
Expand Down
1 change: 0 additions & 1 deletion src/optimize/base_optimizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ class BaseOptimizer {
module: {
loaders: [
{ test: /\.less$/, loader: makeStyleLoader('less-loader') },
{ test: /\.scss$/, loader: makeStyleLoader('sass-loader') },
{ test: /\.css$/, loader: makeStyleLoader() },
{ test: /\.jade$/, loader: 'jade-loader' },
{ test: /\.json$/, loader: 'json-loader' },
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/autoload/styles.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Kibana UI Framework
require('../../../ui_framework/components/index.scss');
require('../../../../ui_framework/dist/ui_framework.css');

// All Kibana styles inside of the /styles dir
const context = require.context('../styles', false, /[\/\\](?!mixins|variables|_|\.)[^\/\\]+\.less/);
Expand Down
1 change: 1 addition & 0 deletions tasks/config/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = function (grunt) {
options: { mode: true },
src: [
'src/**',
'ui_framework/dist/**',
'bin/**',
'webpackShims/**',
'config/kibana.yml',
Expand Down
76 changes: 76 additions & 0 deletions tasks/ui_framework.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
const sass = require('node-sass');
const postcss = require('postcss');
const postcssConfig = require('../src/optimize/postcss.config');
const chokidar = require('chokidar');
const debounce = require('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' : './node_modules/.bin/webpack-dev-server',
args: [
'--config=ui_framework/doc_site/webpack.config.js',
'--hot ',
'--inline',
'--content-base=ui_framework/doc_site/build'
],
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((resolve, reject) => {
debouncedCompile();

chokidar.watch('ui_framework/components', { ignoreInitial: true }).on('all', (event, path) => {
grunt.log.writeln(event, path);
debouncedCompile();
});
});
}
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit b190867

Please sign in to comment.