Skip to content

Commit dcf1f9d

Browse files
committed
Updated discovery, fixed styles isolation
1 parent 107b784 commit dcf1f9d

File tree

8 files changed

+3547
-116
lines changed

8 files changed

+3547
-116
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.6.2 (18-02-2020)
2+
3+
* Updated `discovery` to `1.0.0-beta.30`
4+
* CSS style isolation via `discovery-cli`
5+
* Fixed issue with suggestion popup on `report` page
6+
17
## 1.6.1 (18-02-2020)
28

39
* Updated `discovery` to `1.0.0-beta.28` and `jora` to `1.0.0-alpha.13`

core/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
WRAPPER_NODE: 'json-discovery-browser-extension'
2+
CSS_ISOLATE_MARKER: 'style-boundary-8H37xEyN'
33
};

core/cssTransformLoader.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

core/isolateCss.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const { bundleCss } = require('@discoveryjs/cli').build;
2+
const { CSS_ISOLATE_MARKER } = require('../core/constants');
3+
4+
const isolateOptions = {
5+
isolate: CSS_ISOLATE_MARKER
6+
};
7+
8+
/**
9+
* Css Transform loader
10+
* @param {string} source
11+
*/
12+
module.exports = function() {
13+
const callback = this.async();
14+
15+
bundleCss(this.resourcePath, isolateOptions)
16+
.then(({ content }) => callback(null, content))
17+
.catch(error => callback(error));
18+
};

core/webpack.base.js

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
const webpack = require('webpack');
12
const path = require('path');
23
const CopyWebpackPlugin = require('copy-webpack-plugin');
34
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
45
const pkg = require('../package.json');
56
const manifestBase = require('../src/manifest.js');
67
const manifestFirefox = require('../src/manifest-firefox.js');
8+
const { CSS_ISOLATE_MARKER } = require('./constants');
79

810
const resolve = dir => path.join(__dirname, '..', 'src', dir);
911
const config = ({ entry = resolve('./content/inject'), manifest, outputPath, staticCopy = true }) => ({
@@ -36,7 +38,6 @@ const config = ({ entry = resolve('./content/inject'), manifest, outputPath, sta
3638
rules: [
3739
{
3840
test: /\.css$/,
39-
exclude: /discovery\.css$/,
4041
use: [
4142
{
4243
loader: MiniCssExtractPlugin.loader
@@ -48,21 +49,7 @@ const config = ({ entry = resolve('./content/inject'), manifest, outputPath, sta
4849
}
4950
},
5051
{
51-
loader: require.resolve('./cssTransformLoader.js')
52-
}
53-
]
54-
},
55-
{
56-
test: /discovery\.css$/,
57-
use: [
58-
{
59-
loader: MiniCssExtractPlugin.loader
60-
},
61-
{
62-
loader: 'css-loader',
63-
options: {
64-
import: true
65-
}
52+
loader: require.resolve('./isolateCss.js')
6653
}
6754
]
6855
},
@@ -103,6 +90,9 @@ const config = ({ entry = resolve('./content/inject'), manifest, outputPath, sta
10390
]
10491
},
10592
plugins: [
93+
new webpack.DefinePlugin({
94+
CSS_ISOLATE_MARKER: JSON.stringify(CSS_ISOLATE_MARKER)
95+
}),
10696
new CopyWebpackPlugin([
10797
...staticCopy ? [{
10898
from: path.join(__dirname, '..', 'static')

0 commit comments

Comments
 (0)