sku 12.2.0 → 12.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # sku
2
2
 
3
+ ## 12.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Allow importing external CSS from `node_modules`. ([#861](https://github.com/seek-oss/sku/pull/861))
8
+
9
+ CSS from third-party dependencies can be loaded using a side-effect import, e.g.
10
+
11
+ ```tsx
12
+ import { SomeComponent } from 'some-package';
13
+
14
+ import 'some-package/dist/styles.css';
15
+
16
+ export const MyComponent = () => {
17
+ return <SomeComponent>{/* ... */}</SomeComponent>;
18
+ };
19
+ ```
20
+
3
21
  ## 12.2.0
4
22
 
5
23
  ### Minor Changes
@@ -26,7 +26,8 @@ module.exports = ({ config }, { isDevServer }) => {
26
26
  : [previousExclude]), // Ensure we don't clobber any existing exclusions
27
27
  ...paths.src,
28
28
  ...paths.compilePackages.map(resolvePackage),
29
- /\.vanilla\.css$/,
29
+ /\.vanilla\.css$/, // Vanilla Extract virtual modules
30
+ /\.css$/, // external CSS
30
31
  ];
31
32
  });
32
33
  }
@@ -5,7 +5,7 @@ const { VanillaExtractPlugin } = require('@vanilla-extract/webpack-plugin');
5
5
  const {
6
6
  makeJsLoaders,
7
7
  makeCssLoaders,
8
- makeVanillaCssLoaders,
8
+ makeExternalCssLoaders,
9
9
  makeSvgLoaders,
10
10
  TYPESCRIPT,
11
11
  JAVASCRIPT,
@@ -148,18 +148,35 @@ class SkuWebpackPlugin {
148
148
  }),
149
149
  },
150
150
  {
151
- // All CSS created by vanilla-extract
152
- test: /\.vanilla.css$/i,
153
- // Don't process vanilla files from Playroom as they are handled separately.
154
- // Virtual file paths will look more realistic in the future allowing
155
- // more standard handling of include/exclude path matching.
156
- exclude: /node_modules\/playroom/,
157
- use: makeVanillaCssLoaders({
158
- isProductionBuild,
159
- MiniCssExtractPlugin,
160
- hot,
161
- browserslist,
162
- }),
151
+ test: /\.css$/i,
152
+ oneOf: [
153
+ {
154
+ // All CSS created by vanilla-extract
155
+ test: /\.vanilla\.css$/i,
156
+ // Don't process vanilla files from Playroom as they are handled separately.
157
+ // Virtual file paths will look more realistic in the future allowing
158
+ // more standard handling of include/exclude path matching.
159
+ exclude: /node_modules\/playroom/,
160
+ use: makeExternalCssLoaders({
161
+ isProductionBuild,
162
+ MiniCssExtractPlugin,
163
+ hot,
164
+ browserslist,
165
+ }),
166
+ },
167
+ {
168
+ test: /\.css$/i,
169
+ include: /node_modules/,
170
+ exclude: /node_modules\/playroom/,
171
+ use: makeExternalCssLoaders({
172
+ target,
173
+ isProductionBuild,
174
+ MiniCssExtractPlugin,
175
+ hot,
176
+ browserslist,
177
+ }),
178
+ },
179
+ ],
163
180
  },
164
181
  {
165
182
  test: IMAGE,
@@ -91,18 +91,18 @@ const makeCssLoaders = (options = {}) => {
91
91
  },
92
92
  ]
93
93
  : []),
94
-
95
94
  {
96
95
  loader: require.resolve('less-loader'),
97
96
  },
98
97
  ];
99
98
  };
100
99
 
101
- const makeVanillaCssLoaders = (options = {}) => {
102
- const { isProductionBuild, MiniCssExtractPlugin, browserslist } = options;
100
+ const makeExternalCssLoaders = (options = {}) => {
101
+ const { target, isProductionBuild, MiniCssExtractPlugin, browserslist } =
102
+ options;
103
103
 
104
104
  return [
105
- MiniCssExtractPlugin.loader,
105
+ ...(!target || target === 'browser' ? [MiniCssExtractPlugin.loader] : []),
106
106
  {
107
107
  loader: require.resolve('css-loader'),
108
108
  options: {
@@ -162,6 +162,6 @@ const makeSvgLoaders = () => [
162
162
  module.exports = {
163
163
  makeJsLoaders,
164
164
  makeCssLoaders,
165
- makeVanillaCssLoaders,
165
+ makeExternalCssLoaders,
166
166
  makeSvgLoaders,
167
167
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sku",
3
- "version": "12.2.0",
3
+ "version": "12.3.0",
4
4
  "description": "Front-end development toolkit, powered by Webpack, Babel, CSS Modules, Less and Jest",
5
5
  "main": "index.js",
6
6
  "bin": {