@oroinc/oro-webpack-config-builder 5.1.0-alpha34 → 5.1.0-alpha36

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.
@@ -8,7 +8,7 @@ class LayoutModulesConfigLoader extends ModulesConfigLoader {
8
8
  */
9
9
  loadConfig(theme, filePath) {
10
10
  let themeConfig = super.loadConfig(theme, path.join('Resources/views/layouts/', theme, filePath));
11
-
11
+ themeConfig = merge(themeConfig, super.loadConfig(theme, path.join('templates/layouts/', theme, filePath)));
12
12
  // recursive process parent theme
13
13
  const {parent: parentTheme} = this.themes[theme];
14
14
  if (typeof parentTheme === 'string') {
@@ -38,24 +38,34 @@ class ModulesConfigLoader {
38
38
 
39
39
  /**
40
40
  * @param {Array} bundles Array of ordered symfony bundle paths
41
- * @param {string} themesLocation Path inside the bundle, where to find the theme
41
+ * @param {string|Array} themesLocation Path inside the bundle, where to find the theme
42
42
  * @param {string} themeInfoFileName Yaml File name with theme info
43
43
  */
44
44
  constructor(bundles, themesLocation, themeInfoFileName) {
45
45
  this._bundles = bundles;
46
- this._themes = this._getThemes(themesLocation, themeInfoFileName);
46
+ if (!Array.isArray(themesLocation)) {
47
+ themesLocation = [themesLocation];
48
+ }
49
+
50
+ const themes = {};
51
+ const self = this;
52
+ themesLocation.forEach(themesLocation => {
53
+ self._collectThemes(themes, themesLocation, themeInfoFileName);
54
+ });
55
+
56
+ this._themes = themes;
47
57
  this._processedFiles = [];
48
58
  }
49
59
 
50
60
  /**
51
- * Return list of themes with their parents
61
+ * Collects list of themes with their parents into given storage(themes param)
62
+ *
63
+ * @param {Object} themes
52
64
  * @param {string} themesLocation
53
65
  * @param {string} themeInfoFileName
54
- * @returns {Object.<string|null>}
55
66
  * @private
56
67
  */
57
- _getThemes(themesLocation, themeInfoFileName) {
58
- const themes = {};
68
+ _collectThemes(themes, themesLocation, themeInfoFileName) {
59
69
  this._bundles.forEach(bundle => {
60
70
  const source = bundle + themesLocation;
61
71
 
@@ -73,8 +83,6 @@ class ModulesConfigLoader {
73
83
  themes[name] = merge(themes[name] || {}, theme, {arrayMerge});
74
84
  });
75
85
  });
76
-
77
- return themes;
78
86
  }
79
87
 
80
88
  /**
@@ -32,6 +32,7 @@ require('resolve-url-loader');
32
32
 
33
33
  class ConfigBuilder {
34
34
  constructor() {
35
+ this._projectPath = '';
35
36
  this._enableLayoutThemes = false;
36
37
  this._defaultLayoutThemes = null;
37
38
  this.emitter = new EventEmitter();
@@ -186,6 +187,13 @@ class ConfigBuilder {
186
187
  };
187
188
  }
188
189
 
190
+ get resolvedProjectPath() {
191
+ if (this._resolvedProjectPath == undefined) {
192
+ this._resolvedProjectPath = path.resolve(this._projectPath);
193
+ }
194
+ return this._resolvedProjectPath;
195
+ }
196
+
189
197
  get resolvedPublicPath() {
190
198
  if (this._resolvedPublicPath === undefined) {
191
199
  this._resolvedPublicPath = path.resolve(this._publicPath);
@@ -433,9 +441,14 @@ class ConfigBuilder {
433
441
  if (this._isAdminTheme(buildName)) {
434
442
  themeDefinition = this._modulesConfigLoader.themes[buildName.split('.')[1]];
435
443
  buildPublicPath = '/build/admin/';
436
- const jsModulesConfig = this._themeConfigFactory.loadConfig(buildName,
437
- ['Resources/config/oro/jsmodules.yml', 'Resources/config/jsmodules.yml']);
438
- validation.jsmodulesValidator.checkFullSchema(
444
+ const jsModulesConfig = this._themeConfigFactory.loadConfig(
445
+ buildName,
446
+ [
447
+ 'Resources/config/oro/jsmodules.yml',
448
+ 'Resources/config/jsmodules.yml',
449
+ 'config/oro/jsmodules.yml'
450
+ ]
451
+ ); validation.jsmodulesValidator.checkFullSchema(
439
452
  jsModulesConfig,
440
453
  this._themeConfigFactory?._configLoader.processedFiles,
441
454
  buildName
@@ -473,6 +486,7 @@ class ConfigBuilder {
473
486
  modules: [
474
487
  resolvedBuildPath,
475
488
  this.resolvedPublicPath,
489
+ path.join(this.resolvedProjectPath, '/assets'),
476
490
  path.join(this.resolvedPublicPath, '/bundles'),
477
491
  path.join(this.resolvedPublicPath, '/js'),
478
492
  this.resolvedNodeModulesPath
@@ -537,10 +551,11 @@ class ConfigBuilder {
537
551
  this._isProduction = args.mode === 'production';
538
552
  this._symfonyEnv = env.symfony;
539
553
  this._appConfig = AppConfigLoader.getConfig(this._cachePath, this._symfonyEnv);
554
+ this._appConfig.paths.push(this.resolvedProjectPath);
540
555
 
541
556
  this._modulesConfigLoader = new ModulesConfigLoader(
542
557
  this._appConfig.paths,
543
- '/Resources/public/themes/',
558
+ ['/Resources/public/themes/', '/public/themes/admin/'],
544
559
  'settings.yml'
545
560
  );
546
561
  this._adminThemes = this._modulesConfigLoader.themeNames.map(themeName => 'admin.' + themeName);
@@ -554,7 +569,7 @@ class ConfigBuilder {
554
569
 
555
570
  this._layoutModulesConfigLoader = new LayoutModulesConfigLoader(
556
571
  this._appConfig.paths,
557
- '/Resources/views/layouts/',
572
+ ['/Resources/views/layouts/', '/templates/layouts/'],
558
573
  'theme.yml'
559
574
  );
560
575
  this._layoutStyleLoader = new LayoutStyleLoader(this._layoutModulesConfigLoader, entryPointFileWriter);
package/package.json CHANGED
@@ -1,49 +1,49 @@
1
1
  {
2
2
  "name": "@oroinc/oro-webpack-config-builder",
3
- "version": "5.1.0-alpha34",
3
+ "version": "5.1.0-alpha36",
4
4
  "author": "Oro, Inc (https://www.oroinc.com)",
5
5
  "license": "MIT",
6
6
  "description": "An integration of OroPlatform based applications with the Webpack.",
7
7
  "main": "oro-webpack-config.js",
8
8
  "dependencies": {
9
- "@babel/core": "~7.17.9",
10
- "@babel/plugin-transform-runtime": "~7.17.0",
11
- "@babel/preset-env": "~7.16.11",
12
- "autoprefixer": "~10.4.0",
13
- "babel-loader": "~8.2.3",
9
+ "@babel/core": "~7.19.3",
10
+ "@babel/plugin-transform-runtime": "~7.19.1",
11
+ "@babel/preset-env": "~7.19.3",
12
+ "autoprefixer": "~10.4.12",
13
+ "babel-loader": "~8.2.5",
14
14
  "bindings": "~1.5.0",
15
15
  "css-loader": "~6.7.1",
16
- "css-minimizer-webpack-plugin": "~3.4.1",
16
+ "css-minimizer-webpack-plugin": "~4.2.0",
17
17
  "deepmerge": "~4.2.2",
18
- "exports-loader": "~3.1.0",
19
- "expose-loader": "~3.1.0",
18
+ "exports-loader": "~4.0.0",
19
+ "expose-loader": "~4.0.0",
20
20
  "extract-loader": "~5.1.0",
21
21
  "file-loader": "~6.2.0",
22
22
  "happypack": "~5.0.1",
23
23
  "html-webpack-plugin": "~5.5.0",
24
- "imports-loader": "~3.1.1",
24
+ "imports-loader": "~4.0.1",
25
25
  "js-yaml": "~4.1.0",
26
- "mini-css-extract-plugin": "~2.6.0",
26
+ "mini-css-extract-plugin": "~2.6.1",
27
27
  "minimist": "~1.2.3",
28
- "nan": "~2.15.0",
28
+ "nan": "~2.16.0",
29
29
  "path": "0.12.7",
30
- "postcss": "~8.4.5",
31
- "postcss-loader": "~6.2.0",
30
+ "postcss": "~8.4.17",
31
+ "postcss-loader": "~7.0.1",
32
32
  "printf": "~0.6.0",
33
33
  "resolve-url-loader": "^5.0.0",
34
34
  "rtlcss-webpack-plugin": "~4.0.6",
35
- "sass": "~1.50.0",
36
- "sass-loader": "~12.6.0",
35
+ "sass": "~1.55.0",
36
+ "sass-loader": "~13.0.2",
37
37
  "schema-utils": "^4.0.0",
38
38
  "style-loader": "~3.3.1",
39
- "terser": "~5.12.1",
39
+ "terser": "~5.15.0",
40
40
  "text-loader": "0.0.1",
41
- "underscore": "~1.13.1",
41
+ "underscore": "1.13.*",
42
42
  "url-loader": "~4.1.1",
43
- "webpack": "~5.72.0",
44
- "webpack-bundle-analyzer": "~4.5.0",
45
- "webpack-cli": "~4.9.1",
46
- "webpack-dev-server": "^4.7.3",
43
+ "webpack": "~5.74.0",
44
+ "webpack-bundle-analyzer": "~4.6.1",
45
+ "webpack-cli": "~4.10.0",
46
+ "webpack-dev-server": "^4.11.1",
47
47
  "webpack-merge": "~5.8.0",
48
48
  "wildcard": "~2.0.0"
49
49
  }
@@ -9,8 +9,9 @@ class AdminStyleLoader extends StyleLoader {
9
9
  const {rtl_support: rtlSupport = false, styles: extraThemeConfig} =
10
10
  this._configLoader.loadConfig(themeName, 'Resources/public/themes/' + themeName + '/settings.yml');
11
11
  const baseThemeConfig = this._configLoader.loadConfig(themeName, 'Resources/config/oro/assets.yml');
12
+ const appRootExtraConfig = this._configLoader.loadConfig(themeName, 'config/oro/assets.yml');
12
13
  /** @type {Object.<string, ThemeGroupConfig>} */
13
- const themeConfig = merge(baseThemeConfig, extraThemeConfig);
14
+ const themeConfig = merge(baseThemeConfig, appRootExtraConfig, extraThemeConfig);
14
15
 
15
16
  return {
16
17
  themeConfig,
@@ -49,6 +49,7 @@ class StyleLoader {
49
49
 
50
50
  inputs = this._overrideInputs(inputs);
51
51
  inputs = this._sortInputs(inputs);
52
+ inputs = this._applyInputsBasePathPrefix(inputs);
52
53
 
53
54
  if (settings.rtlSupport) {
54
55
  writingOptions.ignoreRTLInputs = _.difference(inputs, this._matchInputs(rtlMasks, inputs));
@@ -58,7 +59,7 @@ class StyleLoader {
58
59
  const filePath = path.join(buildPath, output);
59
60
  entryPoints[entryPointName] = [
60
61
  ...entries,
61
- this._entryPointFileWriter.write('./../../../', inputs, filePath, writingOptions)
62
+ this._entryPointFileWriter.write('./../../', inputs, filePath, writingOptions)
62
63
  ];
63
64
  }
64
65
  return entryPoints;
@@ -153,6 +154,7 @@ class StyleLoader {
153
154
  * @protected
154
155
  */
155
156
  _matchInputs(masks, inputs) {
157
+ masks = this._applyInputsBasePathPrefix(masks);
156
158
  masks = masks.map(mask => wildcard(mask));
157
159
 
158
160
  const whiteListedInputs = masks.reduce((include, mask) => {
@@ -162,6 +164,26 @@ class StyleLoader {
162
164
 
163
165
  return _.unique(whiteListedInputs);
164
166
  }
167
+
168
+ /**
169
+ * Considering base path as application's root.
170
+ * Bundles based *.scss sources go with '../' prefix.
171
+ *
172
+ * @param {string[]} inputs
173
+ * @private
174
+ */
175
+ _applyInputsBasePathPrefix(inputs) {
176
+ const processedInputs = [];
177
+
178
+ inputs.forEach(input => {
179
+ if (input.indexOf('bundles') === 0) {
180
+ input = '../' + input;
181
+ }
182
+ processedInputs.push(input);
183
+ });
184
+
185
+ return processedInputs;
186
+ }
165
187
  }
166
188
 
167
189
  module.exports = StyleLoader;
@@ -82,10 +82,11 @@ module.exports = Object.assign({}, schemaValidator, {
82
82
  input = newPath;
83
83
  }
84
84
 
85
+ const fullBasePath = path.resolve(input);
85
86
  const fullPath = path.resolve(this._publicPath + input);
86
87
  // skip the path to global node modules,
87
88
  // e.g. '~bootstrap/scss/bootstrap'
88
- if (!input.startsWith('~') && !fs.existsSync(fullPath)) {
89
+ if (!input.startsWith('~') && !fs.existsSync(fullPath) && !fs.existsSync(fullBasePath)) {
89
90
  files.push(input);
90
91
  }
91
92
  });