Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] Include X-Pack plugins for SCSS builds #22325

Merged
merged 1 commit into from
Aug 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core_plugins/kibana/public/discover/_index.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import 'components/fetch_error/index';
@import 'directives/index';

@import '../../../../ui/public/styles/local_search';
@import 'ui/public/styles/local_search';

@import 'hacks';

Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/kibana/public/index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../../../src/ui/public/styles/styling_constants';
@import 'ui/public/styles/styling_constants';

// Discover styles
@import './discover/index';
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/status_page/public/index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../../ui/public/styles/styling_constants';
@import 'ui/public/styles/styling_constants';

// SASSTODO: Remove when K7 applies background color to body
.stsPage {
Expand Down
4 changes: 3 additions & 1 deletion src/dev/build/tasks/transpile_scss_task.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export const TranspileScssTask = {

async run(config, log, build) {
const scanDirs = [ build.resolvePath('src/core_plugins') ];
const { spec$ } = findPluginSpecs({ plugins: { scanDirs, paths: [] } });
const paths = [ build.resolvePath('node_modules/x-pack') ];

const { spec$ } = findPluginSpecs({ plugins: { scanDirs, paths } });
const enabledPlugins = await spec$.pipe(toArray()).toPromise();

try {
Expand Down
4 changes: 4 additions & 0 deletions src/server/sass/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ export class Build {
outFile,
sourceMap: true,
sourceMapEmbed: true,
includePaths: [
path.resolve(__dirname, '../..'),
path.resolve(__dirname, '../../../node_modules')
]
});


Expand Down
16 changes: 8 additions & 8 deletions src/server/sass/build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/

import path from 'path';
import sass from 'node-sass';
import { Build } from './build';

Expand All @@ -27,24 +28,23 @@ describe('SASS builder', () => {

it('generates a glob', () => {
const builder = new Build('/foo/style.sass');
expect(builder.getGlob()).toEqual('/foo/**/*.s{a,c}ss');
expect(builder.getGlob()).toEqual(path.join('/foo', '**', '*.s{a,c}ss'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the significance of us doing a path.join here? Was it to be directory separator platform agnostic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was required to get it to pass on Windows as well.

});

it('builds SASS', () => {
sass.render.mockImplementation(() => Promise.resolve(null, { css: 'test' }));
const builder = new Build('/foo/style.sass');
builder.build();

expect(sass.render.mock.calls[0][0]).toEqual({
file: '/foo/style.sass',
outFile: '/foo/style.css',
sourceMap: true,
sourceMapEmbed: true
});
const sassCall = sass.render.mock.calls[0][0];
expect(sassCall.file).toEqual('/foo/style.sass');
expect(sassCall.outFile).toEqual(path.join('/foo', 'style.css'));
expect(sassCall.sourceMap).toBe(true);
expect(sassCall.sourceMapEmbed).toBe(true);
});

it('has an output file with a different extension', () => {
const builder = new Build('/foo/style.sass');
expect(builder.outputPath()).toEqual('/foo/style.css');
expect(builder.outputPath()).toEqual(path.join('/foo', 'style.css'));
});
});
10 changes: 5 additions & 5 deletions src/ui/public/styles/_styling_constants.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// EUI global scope
@import '../../../../node_modules/@elastic/eui/src/themes/k6/k6_globals';
@import '../../../../node_modules/@elastic/eui/src/themes/k6/k6_colors_light';
@import '../../../../node_modules/@elastic/eui/src/global_styling/functions/index';
@import '../../../../node_modules/@elastic/eui/src/global_styling/variables/index';
@import '../../../../node_modules/@elastic/eui/src/global_styling/mixins/index';
@import '@elastic/eui/src/themes/k6/k6_globals';
@import '@elastic/eui/src/themes/k6/k6_colors_light';
@import '@elastic/eui/src/global_styling/functions/index';
@import '@elastic/eui/src/global_styling/variables/index';
@import '@elastic/eui/src/global_styling/mixins/index';

// EUI TODO: Add this
@mixin kibanaCircleLogo() {
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/dashboard_mode/public/index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@import '../../../../src/ui/public/styles/styling_constants';
@import 'ui/public/styles/styling_constants';

@import '../../../../src/core_plugins/kibana/public/dashboard/index';
@import 'core_plugins/kibana/public/dashboard/index';
2 changes: 1 addition & 1 deletion x-pack/plugins/monitoring/public/index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Import the EUI global scope so we can use EUI constants
@import '../../../../src/ui/public/styles/_styling_constants';
@import 'ui/public/styles/_styling_constants';

// Temporary hacks
@import 'hacks';
Expand Down