@oroinc/oro-webpack-config-builder 5.1.0-alpha28 → 5.1.0-alpha31
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/messages.js +29 -0
- package/oro-webpack-config.js +17 -2
- package/package.json +38 -38
- package/style/style-loader.js +8 -2
- package/theme-config-factory.js +8 -2
package/messages.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const doc = "Please, find more information in the documentation ";
|
|
2
|
+
const CSSError = "Failed assembly styles.\n";
|
|
3
|
+
const CSSDoc = "https://doc.oroinc.com/backend/bundles/platform/AssetBundle/#load-scss-or-css-files-from-the-bundle";
|
|
4
|
+
const JSError = `Failed assembly JS.\n`;
|
|
5
|
+
const JSDoc = "https://doc.oroinc.com/backend/bundles/platform/AssetBundle/#create-jsmodules-yml-configuration";
|
|
6
|
+
const JSExtraBuildDoc = "https://doc.oroinc.com/master/frontend/storefront/how-to/how-to-create-extra-js-build-for-landing-page";
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
assetsMissedOutput(group, theme) {
|
|
10
|
+
const error = `The "output" for "${group}" entry point in "${theme}" theme is not defined.\n`;
|
|
11
|
+
|
|
12
|
+
return `${CSSError}${error}${doc}${CSSDoc}`;
|
|
13
|
+
},
|
|
14
|
+
assetsMissedInput(group, theme) {
|
|
15
|
+
const error = `The "output" for "${group}" entry point in "${theme}" theme is not defined.\n`;
|
|
16
|
+
|
|
17
|
+
return `${CSSError}${error}${doc}${CSSDoc}`
|
|
18
|
+
},
|
|
19
|
+
jsModulesError(theme) {
|
|
20
|
+
const error = `Failed assembly JS for the "${theme}" theme.\n`;
|
|
21
|
+
|
|
22
|
+
return `${error}${doc}${JSDoc}`
|
|
23
|
+
},
|
|
24
|
+
jsExtraModulesError(parts) {
|
|
25
|
+
const error = `Sections ["${parts.join('", "')}"] are not allowed in extra js build definition\n`;
|
|
26
|
+
|
|
27
|
+
return `${JSError}${error}${doc}${JSExtraBuildDoc}`;
|
|
28
|
+
}
|
|
29
|
+
};
|
package/oro-webpack-config.js
CHANGED
|
@@ -23,6 +23,7 @@ const resolve = require('enhanced-resolve');
|
|
|
23
23
|
const {merge: webpackMerge} = require('webpack-merge');
|
|
24
24
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
25
25
|
const RtlCssWebpackPlugin = require('rtlcss-webpack-plugin');
|
|
26
|
+
const {red: colorRed} = require('colorette');
|
|
26
27
|
require('resolve-url-loader');
|
|
27
28
|
|
|
28
29
|
class ConfigBuilder {
|
|
@@ -127,12 +128,26 @@ class ConfigBuilder {
|
|
|
127
128
|
return (env = {}, args = {}) => {
|
|
128
129
|
this._initialize(args, env);
|
|
129
130
|
|
|
130
|
-
|
|
131
|
+
let commonConfig = {};
|
|
132
|
+
try {
|
|
133
|
+
commonConfig = this._getCommonWebpackConfig(args, env);
|
|
134
|
+
} catch (e) {
|
|
135
|
+
console.error(colorRed(`Error: ${e.message}`));
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
|
|
131
139
|
const webpackConfigs = [];
|
|
132
140
|
const requestedBuildNames = env.theme ? env.theme.split(',') : [];
|
|
133
141
|
const buildNames = this._getBuildNames(requestedBuildNames);
|
|
134
142
|
buildNames.forEach(buildName => {
|
|
135
|
-
|
|
143
|
+
let buildConfig;
|
|
144
|
+
try {
|
|
145
|
+
buildConfig = this._getThemeWebpackConfig(buildName, args, env);
|
|
146
|
+
} catch (e) {
|
|
147
|
+
console.error(colorRed(`Error: ${e.message}`));
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
136
151
|
if (buildConfig) {
|
|
137
152
|
webpackConfigs.push(webpackMerge(buildConfig, commonConfig));
|
|
138
153
|
}
|
package/package.json
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oroinc/oro-webpack-config-builder",
|
|
3
|
-
"version": "5.1.0-
|
|
3
|
+
"version": "5.1.0-alpha31",
|
|
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": "
|
|
10
|
-
"@babel/plugin-transform-runtime": "
|
|
11
|
-
"@babel/preset-env": "
|
|
12
|
-
"autoprefixer": "
|
|
13
|
-
"babel-loader": "
|
|
14
|
-
"bindings": "
|
|
15
|
-
"css-loader": "
|
|
16
|
-
"css-minimizer-webpack-plugin": "
|
|
17
|
-
"deepmerge": "
|
|
18
|
-
"exports-loader": "
|
|
19
|
-
"expose-loader": "
|
|
20
|
-
"extract-loader": "
|
|
21
|
-
"file-loader": "
|
|
22
|
-
"happypack": "
|
|
23
|
-
"html-webpack-plugin": "
|
|
24
|
-
"imports-loader": "
|
|
25
|
-
"js-yaml": "
|
|
26
|
-
"mini-css-extract-plugin": "
|
|
27
|
-
"minimist": "
|
|
28
|
-
"nan": "
|
|
9
|
+
"@babel/core": "~7.16.0",
|
|
10
|
+
"@babel/plugin-transform-runtime": "~7.16.0",
|
|
11
|
+
"@babel/preset-env": "~7.16.0",
|
|
12
|
+
"autoprefixer": "~10.4.0",
|
|
13
|
+
"babel-loader": "~8.2.3",
|
|
14
|
+
"bindings": "~1.5.0",
|
|
15
|
+
"css-loader": "~6.5.1",
|
|
16
|
+
"css-minimizer-webpack-plugin": "~3.1.3",
|
|
17
|
+
"deepmerge": "~4.2.2",
|
|
18
|
+
"exports-loader": "~3.1.0",
|
|
19
|
+
"expose-loader": "~3.1.0",
|
|
20
|
+
"extract-loader": "~5.1.0",
|
|
21
|
+
"file-loader": "~6.2.0",
|
|
22
|
+
"happypack": "~5.0.1",
|
|
23
|
+
"html-webpack-plugin": "~5.5.0",
|
|
24
|
+
"imports-loader": "~3.1.1",
|
|
25
|
+
"js-yaml": "~4.1.0",
|
|
26
|
+
"mini-css-extract-plugin": "~2.4.4",
|
|
27
|
+
"minimist": "~1.2.3",
|
|
28
|
+
"nan": "~2.15.0",
|
|
29
29
|
"path": "0.12.7",
|
|
30
|
-
"postcss": "
|
|
31
|
-
"postcss-loader": "
|
|
32
|
-
"printf": "
|
|
33
|
-
"resolve-url-loader": "
|
|
34
|
-
"rtlcss-webpack-plugin": "
|
|
35
|
-
"sass": "
|
|
36
|
-
"sass-loader": "
|
|
37
|
-
"style-loader": "
|
|
38
|
-
"terser": "
|
|
30
|
+
"postcss": "~8.3.11",
|
|
31
|
+
"postcss-loader": "~6.2.0",
|
|
32
|
+
"printf": "~0.6.0",
|
|
33
|
+
"resolve-url-loader": "~4.0.0",
|
|
34
|
+
"rtlcss-webpack-plugin": "~4.0.6",
|
|
35
|
+
"sass": "~1.43.4",
|
|
36
|
+
"sass-loader": "~12.3.0",
|
|
37
|
+
"style-loader": "~3.3.1",
|
|
38
|
+
"terser": "~5.9.0",
|
|
39
39
|
"text-loader": "0.0.1",
|
|
40
|
-
"underscore": "
|
|
41
|
-
"url-loader": "
|
|
42
|
-
"webpack": "
|
|
43
|
-
"webpack-bundle-analyzer": "
|
|
44
|
-
"webpack-cli": "
|
|
45
|
-
"webpack-dev-server": "
|
|
46
|
-
"webpack-merge": "
|
|
47
|
-
"wildcard": "
|
|
40
|
+
"underscore": "~1.13.1",
|
|
41
|
+
"url-loader": "~4.1.1",
|
|
42
|
+
"webpack": "~5.63.0",
|
|
43
|
+
"webpack-bundle-analyzer": "~4.5.0",
|
|
44
|
+
"webpack-cli": "~4.9.1",
|
|
45
|
+
"webpack-dev-server": "~4.4.0",
|
|
46
|
+
"webpack-merge": "~5.8.0",
|
|
47
|
+
"wildcard": "~2.0.0"
|
|
48
48
|
}
|
|
49
49
|
}
|
package/style/style-loader.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const wildcard = require('wildcard');
|
|
3
3
|
const _ = require('underscore');
|
|
4
|
+
const messages = require('../messages')
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @typedef ThemeGroupConfig
|
|
@@ -33,8 +34,13 @@ class StyleLoader {
|
|
|
33
34
|
const writingOptions = {};
|
|
34
35
|
for (const [group, config] of Object.entries(themeConfig)) {
|
|
35
36
|
let {inputs, entries = [], output, auto_rtl_inputs: rtlMasks = []} = config;
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
|
|
38
|
+
if (output === void 0) {
|
|
39
|
+
throw new Error(messages.assetsMissedOutput(group, theme));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (inputs === void 0) {
|
|
43
|
+
throw new Error(messages.assetsMissedInput(group, theme));
|
|
38
44
|
}
|
|
39
45
|
|
|
40
46
|
inputs = this._overrideInputs(inputs);
|
package/theme-config-factory.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const messages = require('./messages');
|
|
2
|
+
|
|
1
3
|
class ThemeConfigFactory {
|
|
2
4
|
/**
|
|
3
5
|
* @param {ModulesConfigLoader} configLoader
|
|
@@ -17,7 +19,11 @@ class ThemeConfigFactory {
|
|
|
17
19
|
* @return {Object} Merged Configs loaded from all the bundles Yaml files matched by filePath
|
|
18
20
|
*/
|
|
19
21
|
loadConfig(theme, configFilepath) {
|
|
20
|
-
|
|
22
|
+
try {
|
|
23
|
+
return this._configLoader.loadConfig(theme, configFilepath)
|
|
24
|
+
} catch (e) {
|
|
25
|
+
throw new Error(messages.jsModulesError(theme));
|
|
26
|
+
}
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
extendConfig(baseConfig, extraConfig) {
|
|
@@ -37,7 +43,7 @@ class ThemeConfigFactory {
|
|
|
37
43
|
|
|
38
44
|
const beyondKeys = Object.keys(rest);
|
|
39
45
|
if (beyondKeys.length) {
|
|
40
|
-
throw new Error(
|
|
46
|
+
throw new Error( messages.jsExtraModulesError(beyondKeys));
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
return {
|