@openedx/frontend-base 1.0.0-alpha.39 → 1.0.0-alpha.40

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.
@@ -0,0 +1 @@
1
+ @layer paragon, shell, app, site, brand;
@@ -1,5 +1,3 @@
1
- @layer paragon, shell, app, site, brand;
2
-
3
1
  .flex-basis-0 {
4
2
  flex-basis: 0 !important;
5
3
  }
@@ -1,2 +1,12 @@
1
1
  import { RuleSetRule } from 'webpack';
2
+ export declare const PARAGON_PACKAGE: {
3
+ name: string;
4
+ };
5
+ export declare const SHELL_PACKAGE: {
6
+ name: string;
7
+ };
8
+ export declare const BRAND_PACKAGE: {
9
+ name: RegExp;
10
+ };
11
+ export declare const APP_RESOURCE: RegExp;
2
12
  export default function getStylesheetRule(mode: 'dev' | 'production'): RuleSetRule;
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.APP_RESOURCE = exports.BRAND_PACKAGE = exports.SHELL_PACKAGE = exports.PARAGON_PACKAGE = void 0;
6
7
  exports.default = getStylesheetRule;
7
8
  const autoprefixer_1 = __importDefault(require("autoprefixer"));
8
9
  const cssnano_1 = __importDefault(require("cssnano"));
@@ -25,10 +26,11 @@ const postcssWrapLayer_1 = __importDefault(require("./postcssWrapLayer"));
25
26
  * precedence of runtime brand CSS (which is injected unlayered via
26
27
  * <link> tags and thus beats every layered rule).
27
28
  */
28
- const PARAGON_RESOURCE = /@openedx[\\/]paragon[\\/]/;
29
- const SHELL_RESOURCE = /(@openedx[\\/]frontend-base|frontend-base[\\/]shell)[\\/]/;
30
- const BRAND_RESOURCE = /@(open)?edx[\\/]brand(-[^\\/]+)?[\\/]/;
31
- const NODE_MODULES = /[\\/]node_modules[\\/]/;
29
+ exports.PARAGON_PACKAGE = { name: '@openedx/paragon' };
30
+ exports.SHELL_PACKAGE = { name: '@openedx/frontend-base' };
31
+ exports.BRAND_PACKAGE = { name: /^@(open)?edx\/brand(-.+)?$/ };
32
+ // The site/app split is positional (my project vs. a dep), so it is path-based.
33
+ exports.APP_RESOURCE = /[\\/](node_modules|packages)[\\/]/;
32
34
  /*
33
35
  * There are a few things we need to do here.
34
36
  *
@@ -43,7 +45,7 @@ function getStylesheetRule(mode) {
43
45
  test: /(.scss|.css)$/,
44
46
  oneOf: [
45
47
  {
46
- resource: PARAGON_RESOURCE,
48
+ descriptionData: exports.PARAGON_PACKAGE,
47
49
  // We need Paragon to not elide CSS: we have to be able to import it
48
50
  // directly from shell/style.ts
49
51
  sideEffects: true,
@@ -53,21 +55,21 @@ function getStylesheetRule(mode) {
53
55
  ],
54
56
  },
55
57
  {
56
- resource: SHELL_RESOURCE,
58
+ descriptionData: exports.SHELL_PACKAGE,
57
59
  use: [
58
60
  mini_css_extract_plugin_1.default.loader,
59
61
  ...getStyleUseConfig(mode, 'shell'),
60
62
  ],
61
63
  },
62
64
  {
63
- resource: BRAND_RESOURCE,
65
+ descriptionData: exports.BRAND_PACKAGE,
64
66
  use: [
65
67
  mini_css_extract_plugin_1.default.loader,
66
68
  ...getStyleUseConfig(mode, 'brand'),
67
69
  ],
68
70
  },
69
71
  {
70
- resource: { not: [NODE_MODULES] },
72
+ resource: { not: [exports.APP_RESOURCE] },
71
73
  use: [
72
74
  getFirstLoader(mode),
73
75
  ...getStyleUseConfig(mode, 'site'),
@@ -6,11 +6,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.default = getHtmlWebpackPlugin;
7
7
  const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
8
8
  const path_1 = __importDefault(require("path"));
9
- // Generates an HTML file in the output directory.
9
+ /*
10
+ * Generates an HTML file in the output directory.
11
+ *
12
+ * `cssLayerOrder` is listed first so its <link> is injected before any other
13
+ * stylesheet. That file contains the `@layer paragon, shell, app, site, brand;`
14
+ * statement, which locks in cascade-layer priority before any layer name is
15
+ * mentioned by the rest of the CSS the browser parses.
16
+ */
10
17
  function getHtmlWebpackPlugin() {
11
18
  return new html_webpack_plugin_1.default({
12
- inject: true, // Appends script tags linking to the webpack bundles at the end of the body
19
+ inject: true,
13
20
  template: path_1.default.resolve(process.cwd(), 'public/index.html'),
14
- chunks: ['app'],
21
+ chunks: ['cssLayerOrder', 'app'],
22
+ chunksSortMode: 'manual',
15
23
  });
16
24
  }
@@ -19,6 +19,7 @@ const config = {
19
19
  mode: 'production',
20
20
  devtool: 'source-map',
21
21
  entry: {
22
+ cssLayerOrder: '@openedx/frontend-base/shell/layer-order.scss',
22
23
  app: '@openedx/frontend-base/shell/site',
23
24
  },
24
25
  output: {
@@ -17,6 +17,7 @@ const resolvedSiteConfigPath = (0, getResolvedSiteConfigPath_1.default)('site.co
17
17
  const resolvedSiteI18nPath = (0, getResolvedSiteI18nPath_1.default)('src/i18n');
18
18
  const config = {
19
19
  entry: {
20
+ cssLayerOrder: '@openedx/frontend-base/shell/layer-order.scss',
20
21
  app: '@openedx/frontend-base/shell/site',
21
22
  },
22
23
  output: {
@@ -19,6 +19,7 @@ const resolvedSiteConfigPath = (0, getResolvedSiteConfigPath_1.default)('shell/s
19
19
  const resolvedSiteI18nPath = (0, getResolvedSiteI18nPath_1.default)('test-site/src/i18n');
20
20
  const config = {
21
21
  entry: {
22
+ cssLayerOrder: path_1.default.resolve(process.cwd(), 'shell/layer-order.scss'),
22
23
  app: path_1.default.resolve(process.cwd(), 'shell/site'),
23
24
  },
24
25
  output: {
@@ -85,9 +86,10 @@ const config = {
85
86
  filename: '[name].css',
86
87
  }),
87
88
  new html_webpack_plugin_1.default({
88
- inject: true, // Appends script tags linking to the webpack bundles at the end of the body
89
+ inject: true,
89
90
  template: path_1.default.resolve(process.cwd(), 'shell/public/index.html'),
90
- chunks: ['app'],
91
+ chunks: ['cssLayerOrder', 'app'],
92
+ chunksSortMode: 'manual',
91
93
  }),
92
94
  new react_refresh_webpack_plugin_1.default(),
93
95
  new fork_ts_checker_webpack_plugin_1.default(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openedx/frontend-base",
3
- "version": "1.0.0-alpha.39",
3
+ "version": "1.0.0-alpha.40",
4
4
  "description": "Build tools, setup and config for frontend apps",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,6 +9,7 @@
9
9
  ".": "./dist/index.js",
10
10
  "./tools": "./dist/tools/index.js",
11
11
  "./tools/tsconfig.json": "./dist/tools/typescript/tsconfig.json",
12
+ "./shell/layer-order.scss": "./dist/shell/layer-order.scss",
12
13
  "./shell/style": "./dist/shell/style.js",
13
14
  "./shell/site": "./dist/shell/site.js"
14
15
  },