Skip to content

Commit 95ac4c1

Browse files
authored
Remove libsass as a dependency (#9803) (#9812)
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>
1 parent 76b886d commit 95ac4c1

File tree

133 files changed

+1098
-11
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+1098
-11
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ selenium
3333
*.swp
3434
*.swo
3535
*.out
36-
src/ui_framework/doc_site/build/*.js*
36+
ui_framework/doc_site/build/*.js*

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"mocha": "mocha",
6464
"mocha:debug": "mocha --debug-brk",
6565
"sterilize": "grunt sterilize",
66-
"uiFramework:start": "webpack-dev-server --config src/ui_framework/doc_site/webpack.config.js --hot --inline --content-base src/ui_framework/doc_site/build"
66+
"uiFramework:start": "grunt uiFramework:start"
6767
},
6868
"repository": {
6969
"type": "git",
@@ -144,7 +144,6 @@
144144
"moment-timezone": "0.5.4",
145145
"no-ui-slider": "1.2.0",
146146
"node-fetch": "1.3.2",
147-
"node-sass": "3.8.0",
148147
"node-uuid": "1.4.7",
149148
"pegjs": "0.9.0",
150149
"postcss-loader": "1.2.1",
@@ -154,7 +153,6 @@
154153
"rimraf": "2.4.3",
155154
"rison-node": "1.0.0",
156155
"rjs-repack-loader": "1.0.6",
157-
"sass-loader": "4.0.0",
158156
"script-loader": "0.6.1",
159157
"semver": "5.1.0",
160158
"style-loader": "0.12.3",
@@ -220,6 +218,7 @@
220218
"mocha": "2.5.3",
221219
"murmurhash3js": "3.0.1",
222220
"ncp": "2.0.0",
221+
"node-sass": "3.8.0",
223222
"nock": "8.0.0",
224223
"npm": "3.10.8",
225224
"portscanner": "1.0.0",
@@ -232,6 +231,7 @@
232231
"react-router-redux": "4.0.4",
233232
"redux": "3.0.0",
234233
"redux-thunk": "0.1.0",
234+
"sass-loader": "4.0.0",
235235
"simple-git": "1.37.0",
236236
"sinon": "1.17.2",
237237
"source-map": "0.5.6",

src/optimize/base_optimizer.js

-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ class BaseOptimizer {
125125
module: {
126126
loaders: [
127127
{ test: /\.less$/, loader: makeStyleLoader('less-loader') },
128-
{ test: /\.scss$/, loader: makeStyleLoader('sass-loader') },
129128
{ test: /\.css$/, loader: makeStyleLoader() },
130129
{ test: /\.jade$/, loader: 'jade-loader' },
131130
{ test: /\.json$/, loader: 'json-loader' },

src/ui/public/autoload/styles.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Kibana UI Framework
2-
require('../../../ui_framework/components/index.scss');
2+
require('../../../../ui_framework/dist/ui_framework.css');
33

44
// All Kibana styles inside of the /styles dir
55
const context = require.context('../styles', false, /[\/\\](?!mixins|variables|_|\.)[^\/\\]+\.less/);

tasks/config/copy.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = function (grunt) {
44
options: { mode: true },
55
src: [
66
'src/**',
7+
'ui_framework/dist/**',
78
'bin/**',
89
'webpackShims/**',
910
'config/kibana.yml',

tasks/ui_framework.js

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
const sass = require('node-sass');
2+
const postcss = require('postcss');
3+
const postcssConfig = require('../src/optimize/postcss.config');
4+
const chokidar = require('chokidar');
5+
const debounce = require('lodash/function/debounce');
6+
const platform = require('os').platform();
7+
8+
module.exports = function (grunt) {
9+
grunt.registerTask('uiFramework:start', function () {
10+
const done = this.async();
11+
Promise.all([uiFrameworkWatch(), uiFrameworkServerStart()]).then(done);
12+
});
13+
14+
function uiFrameworkServerStart() {
15+
const serverCmd = {
16+
cmd: /^win/.test(platform) ? '.\\node_modules\\.bin\\webpack-dev-server' : './node_modules/.bin/webpack-dev-server',
17+
args: [
18+
'--config=ui_framework/doc_site/webpack.config.js',
19+
'--hot ',
20+
'--inline',
21+
'--content-base=ui_framework/doc_site/build'
22+
],
23+
opts: { stdio: 'inherit' }
24+
};
25+
26+
return new Promise((resolve, reject) => {
27+
grunt.util.spawn(serverCmd, (error, result, code) => {
28+
if (error || code !== 0) {
29+
const message = result.stderr || result.stdout;
30+
31+
grunt.log.error(message);
32+
33+
return reject();
34+
}
35+
36+
grunt.log.writeln(result);
37+
38+
resolve();
39+
});
40+
41+
});
42+
}
43+
44+
function uiFrameworkCompile() {
45+
sass.render({
46+
file: 'ui_framework/components/index.scss'
47+
}, function (error, result) {
48+
if (error) {
49+
grunt.log.error(error);
50+
}
51+
52+
postcss([postcssConfig])
53+
.process(result.css, { from: 'ui_framework/components/index.scss', to: 'ui_framework/dist/ui_framework.css' })
54+
.then(result => {
55+
grunt.file.write('ui_framework/dist/ui_framework.css', result.css);
56+
57+
if (result.map) {
58+
grunt.file.write('ui_framework/dist/ui_framework.css.map', result.map);
59+
}
60+
});
61+
});
62+
}
63+
64+
function uiFrameworkWatch() {
65+
const debouncedCompile = debounce(uiFrameworkCompile, 400, { leading: true });
66+
67+
return new Promise((resolve, reject) => {
68+
debouncedCompile();
69+
70+
chokidar.watch('ui_framework/components', { ignoreInitial: true }).on('all', (event, path) => {
71+
grunt.log.writeln(event, path);
72+
debouncedCompile();
73+
});
74+
});
75+
}
76+
};
File renamed without changes.

0 commit comments

Comments
 (0)