-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dev] share sass build with script (#34323)
- Loading branch information
Spencer
authored
Apr 2, 2019
1 parent
8290b56
commit 6703848
Showing
6 changed files
with
154 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
require('../src/setup_node_env'); | ||
require('../src/dev/sass/run_build_sass_cli'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,5 @@ export function getHelp(options: Options) { | |
.join('\n ')} | ||
Options: | ||
${optionHelp} | ||
`; | ||
${optionHelp + '\n\n'}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { resolve } from 'path'; | ||
|
||
import { toArray } from 'rxjs/operators'; | ||
|
||
import { createFailError } from '../run'; | ||
import { findPluginSpecs } from '../../legacy/plugin_discovery'; | ||
import { collectUiExports } from '../../legacy/ui'; | ||
import { buildAll } from '../../legacy/server/sass/build_all'; | ||
|
||
export async function buildSass({ log, kibanaDir }) { | ||
log.info('running plugin discovery in', kibanaDir); | ||
|
||
const scanDirs = [ | ||
resolve(kibanaDir, 'src/legacy/core_plugins') | ||
]; | ||
|
||
const paths = [ | ||
resolve(kibanaDir, 'x-pack'), | ||
resolve(kibanaDir, 'node_modules/x-pack') | ||
]; | ||
|
||
const { spec$ } = findPluginSpecs({ plugins: { scanDirs, paths } }); | ||
const enabledPlugins = await spec$.pipe(toArray()).toPromise(); | ||
const uiExports = collectUiExports(enabledPlugins); | ||
log.info('found %d styleSheetPaths', uiExports.styleSheetPaths.length); | ||
log.verbose(uiExports.styleSheetPaths); | ||
|
||
let bundleCount = 0; | ||
try { | ||
const bundles = await buildAll({ | ||
styleSheets: uiExports.styleSheetPaths, | ||
log, | ||
buildDir: resolve(kibanaDir, 'built_assets/css'), | ||
sourceMap: true | ||
}); | ||
|
||
bundles.forEach(bundle => { | ||
log.debug(`Compiled SCSS: ${bundle.sourcePath} (theme=${bundle.theme})`); | ||
}); | ||
|
||
bundleCount = bundles.length; | ||
} catch (error) { | ||
const { message, line, file } = error; | ||
throw createFailError(`${message} on line ${line} of ${file}`); | ||
} | ||
|
||
log.success('%d scss bundles created', bundleCount); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export { buildSass } from './build_sass'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { run } from '../run'; | ||
import { REPO_ROOT } from '../constants'; | ||
import { buildSass } from './build_sass'; | ||
|
||
run(async ({ log, flags: { kibanaDir } }) => { | ||
await buildSass({ | ||
log, | ||
kibanaDir | ||
}); | ||
}, { | ||
description: 'Simple CLI, useful for building scss files outside of the server', | ||
flags: { | ||
default: { | ||
kibanaDir: REPO_ROOT | ||
}, | ||
string: ['kibanaDir'], | ||
help: ` | ||
--kibanaDir The root of the Kibana directory to build sass files in. | ||
` | ||
}, | ||
}); |