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

[canvas/shareable_runtime] sync sass loaders with kbn/optimizer #60653

Merged
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
55 changes: 50 additions & 5 deletions x-pack/legacy/plugins/canvas/shareable_runtime/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

const path = require('path');
const webpack = require('webpack');
const { stringifyRequest } = require('loader-utils'); // eslint-disable-line

const {
KIBANA_ROOT,
Expand Down Expand Up @@ -140,19 +141,63 @@ module.exports = {
},
{
test: /\.scss$/,
exclude: /\.module.(s(a|c)ss)$/,
exclude: [/node_modules/, /\.module\.s(a|c)ss$/],
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader', options: { importLoaders: 2 } },
{
loader: 'style-loader',
},
{
loader: 'css-loader',
options: {
sourceMap: !isProd,
},
},
{
loader: 'postcss-loader',
options: {
sourceMap: !isProd,
config: {
path: require.resolve('./postcss.config.js'),
path: require.resolve('./postcss.config'),
},
},
},
{
loader: 'resolve-url-loader',
options: {
// eslint-disable-next-line no-unused-vars
join: (_, __) => (uri, base) => {
if (!base) {
return null;
}

// manually force ui/* urls in legacy styles to resolve to ui/legacy/public
if (uri.startsWith('ui/') && base.split(path.sep).includes('legacy')) {
return path.resolve(KIBANA_ROOT, 'src/legacy/ui/public', uri.replace('ui/', ''));
}

return null;
},
},
},
{
loader: 'sass-loader',
options: {
// must always be enabled as long as we're using the `resolve-url-loader` to
// rewrite `ui/*` urls. They're dropped by subsequent loaders though
sourceMap: true,
prependData(loaderContext) {
return `@import ${stringifyRequest(
loaderContext,
path.resolve(KIBANA_ROOT, 'src/legacy/ui/public/styles/_styling_constants.scss')
)};\n`;
},
webpackImporter: false,
sassOptions: {
outputStyle: 'nested',
includePaths: [path.resolve(KIBANA_ROOT, 'node_modules')],
},
},
},
{ loader: 'sass-loader' },
],
},
{
Expand Down
1 change: 1 addition & 0 deletions x-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
"jest-cli": "^24.9.0",
"jest-styled-components": "^7.0.0",
"jsdom": "^15.2.1",
"loader-utils": "^1.2.3",
"madge": "3.4.4",
"marge": "^1.0.1",
"mocha": "^6.2.2",
Expand Down