@studyportals/webpack-helper 2.4.4-beta.0 → 2.5.0-beta.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.
@@ -1,58 +1,58 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const webpack = require('webpack');
4
- const TerserPlugin = require('terser-webpack-plugin');
5
- const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
6
- const DllAvailabilityTracker = require('@studyportals/dll-availability-tracker');
7
- exports.ProductionConfig = (bobConfig) => {
8
- let dllDependencies = ['library'];
9
- if (bobConfig !== null && bobConfig.hasOwnProperty('dllPackages')) {
10
- bobConfig.dllPackages.forEach((dependency) => dllDependencies.push(dependency.manifest.name));
11
- }
12
- return {
13
- plugins: [
14
- new webpack.LoaderOptionsPlugin({
15
- minimize: true
16
- }),
17
- new webpack.DefinePlugin({
18
- 'process.env': {
19
- NODE_ENV: '"production"'
20
- }
21
- }),
22
- new OptimizeCSSAssetsPlugin({
23
- cssProcessorPluginOptions: {
24
- preset: [
25
- 'default',
26
- {
27
- discardComments: {
28
- removeAll: true
29
- }
30
- }
31
- ]
32
- },
33
- }),
34
- new DllAvailabilityTracker({
35
- dependencies: dllDependencies || []
36
- })
37
- ],
38
- optimization: {
39
- minimize: true,
40
- minimizer: [
41
- new TerserPlugin({
42
- sourceMap: true,
43
- parallel: true,
44
- extractComments: false,
45
- terserOptions: {
46
- output: {
47
- comments: false
48
- },
49
- compress: {
50
- drop_console: true,
51
- passes: 5
52
- }
53
- }
54
- })
55
- ]
56
- }
57
- };
58
- };
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ var webpack = require('webpack');
4
+ var TerserPlugin = require('terser-webpack-plugin');
5
+ var OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
6
+ var DllAvailabilityTracker = require('@studyportals/dll-availability-tracker');
7
+ exports.ProductionConfig = function (bobConfig) {
8
+ var dllDependencies = ['library'];
9
+ if (bobConfig !== null && bobConfig.hasOwnProperty('dllPackages')) {
10
+ bobConfig.dllPackages.forEach(function (dependency) { return dllDependencies.push(dependency.manifest.name); });
11
+ }
12
+ return {
13
+ plugins: [
14
+ new webpack.LoaderOptionsPlugin({
15
+ minimize: true
16
+ }),
17
+ new webpack.DefinePlugin({
18
+ 'process.env': {
19
+ NODE_ENV: '"production"'
20
+ }
21
+ }),
22
+ new OptimizeCSSAssetsPlugin({
23
+ cssProcessorPluginOptions: {
24
+ preset: [
25
+ 'default',
26
+ {
27
+ discardComments: {
28
+ removeAll: true
29
+ }
30
+ }
31
+ ]
32
+ }
33
+ }),
34
+ new DllAvailabilityTracker({
35
+ dependencies: dllDependencies || []
36
+ })
37
+ ],
38
+ optimization: {
39
+ minimize: true,
40
+ minimizer: [
41
+ new TerserPlugin({
42
+ sourceMap: true,
43
+ parallel: true,
44
+ extractComments: false,
45
+ terserOptions: {
46
+ output: {
47
+ comments: false
48
+ },
49
+ compress: {
50
+ drop_console: true,
51
+ passes: 5
52
+ }
53
+ }
54
+ })
55
+ ]
56
+ }
57
+ };
58
+ };
package/src/enums/mode.js CHANGED
@@ -1,7 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var Mode;
4
- (function (Mode) {
5
- Mode["DEVELOPMENT"] = "development";
6
- Mode["PRODUCTION"] = "production";
7
- })(Mode = exports.Mode || (exports.Mode = {}));
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ var Mode;
4
+ (function (Mode) {
5
+ Mode["DEVELOPMENT"] = "development";
6
+ Mode["PRODUCTION"] = "production";
7
+ })(Mode = exports.Mode || (exports.Mode = {}));
@@ -1,8 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var Preset;
4
- (function (Preset) {
5
- Preset["VUE_TYPESCRIPT"] = "vue-typescript";
6
- Preset["TYPESCRIPT"] = "typescript";
7
- Preset["JAVASCRIPT"] = "javascript";
8
- })(Preset = exports.Preset || (exports.Preset = {}));
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ var Preset;
4
+ (function (Preset) {
5
+ Preset["VUE_TYPESCRIPT"] = "vue-typescript";
6
+ Preset["TYPESCRIPT"] = "typescript";
7
+ Preset["JAVASCRIPT"] = "javascript";
8
+ })(Preset = exports.Preset || (exports.Preset = {}));
@@ -1,9 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const configuration_1 = require("../model/configuration");
4
- class ConfigurationFactory {
5
- create(options) {
6
- return new configuration_1.Configuration(options);
7
- }
8
- }
9
- exports.ConfigurationFactory = ConfigurationFactory;
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ var configuration_1 = require("../model/configuration");
4
+ var ConfigurationFactory = /** @class */ (function () {
5
+ function ConfigurationFactory() {
6
+ }
7
+ ConfigurationFactory.prototype.create = function (options) {
8
+ return new configuration_1.Configuration(options);
9
+ };
10
+ return ConfigurationFactory;
11
+ }());
12
+ exports.ConfigurationFactory = ConfigurationFactory;
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ exports.__esModule = true;
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ exports.__esModule = true;
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ exports.__esModule = true;
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ exports.__esModule = true;
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ exports.__esModule = true;
@@ -1,116 +1,119 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const entry_1 = require("./entry");
4
- const output_1 = require("./output");
5
- const plugins_1 = require("./plugins");
6
- const module_1 = require("./module");
7
- const preset_1 = require("../enums/preset");
8
- const vue_typescript_preset_1 = require("../presets/vue-typescript.preset");
9
- const typescript_preset_1 = require("../presets/typescript.preset");
10
- const javascript_preset_1 = require("../presets/javascript.preset");
11
- const mode_1 = require("../enums/mode");
12
- const production_config_1 = require("../defaults/production.config");
13
- const development_config_1 = require("../defaults/development.config");
14
- const ManifestGenerator = require("@studyportals/bob-manifest-generator").ManifestGenerator;
15
- const DllReferencePlugin = require("@studyportals/bob-manifest-generator").DllReferencePlugin;
16
- const merge = require("webpack-merge");
17
- class Configuration {
18
- constructor(options) {
19
- this.bob = options.bob || null;
20
- this.entry = new entry_1.Entry(options.entry);
21
- this.output = new output_1.Output(options.output);
22
- this.extensions = options.extensions || [];
23
- this.preset = options.preset || null;
24
- this.hash = options.output.hash || false;
25
- this.plugins = new plugins_1.Plugins(options.plugins);
26
- this.module = new module_1.Module(options.module);
27
- this.commonConfig = options.common || {};
28
- this.environmentSpecificConfig = {
29
- [mode_1.Mode.DEVELOPMENT]: merge([options[mode_1.Mode.DEVELOPMENT], development_config_1.DevelopmentConfig]) || development_config_1.DevelopmentConfig,
30
- [mode_1.Mode.PRODUCTION]: merge([options[mode_1.Mode.PRODUCTION], production_config_1.ProductionConfig(this.bob)]) || production_config_1.ProductionConfig(this.bob)
31
- };
32
- this.detectPresets();
33
- }
34
- get(mode) {
35
- return merge({
36
- entry: this.entry.getEntry(),
37
- output: this.output.getOutput(),
38
- plugins: this.plugins.getPlugins(),
39
- module: this.module.getModule(),
40
- resolve: {
41
- extensions: this.extensions
42
- },
43
- performance: {
44
- hints: false
45
- },
46
- optimization: {
47
- minimize: false
48
- },
49
- devtool: 'source-map'
50
- }, this.getBobConfig(), this.commonConfig, this.getEnvironmentSpecificConfig(mode), { mode });
51
- }
52
- detectPresets() {
53
- switch (this.preset) {
54
- case preset_1.Preset.VUE_TYPESCRIPT:
55
- this.injectPreset(new vue_typescript_preset_1.VueTypeScriptPreset());
56
- break;
57
- case preset_1.Preset.TYPESCRIPT:
58
- this.injectPreset(new typescript_preset_1.TypeScriptPreset());
59
- break;
60
- case preset_1.Preset.JAVASCRIPT:
61
- this.injectPreset(new javascript_preset_1.JavascriptPreset());
62
- break;
63
- default:
64
- break;
65
- }
66
- }
67
- injectPreset(preset) {
68
- const plugins = preset.getPlugins(this.getCSSFileName());
69
- const module = preset.getModule();
70
- plugins.forEach(plugin => {
71
- this.plugins.addPlugin(plugin);
72
- });
73
- this.extensions = this.extensions.concat(preset.getExtensions());
74
- this.module.setModule(module);
75
- }
76
- getEnvironmentSpecificConfig(mode) {
77
- return this.environmentSpecificConfig[mode];
78
- }
79
- getBobConfig() {
80
- if (this.bob === null) {
81
- return {};
82
- }
83
- let dllPackages = [];
84
- if (typeof this.bob.dllPackages !== 'undefined'
85
- && this.bob.dllPackages.length > 0) {
86
- dllPackages = this.getBobDllDependencies();
87
- delete this.bob.dllPackages;
88
- }
89
- return {
90
- plugins: [
91
- new ManifestGenerator(this.bob)
92
- ].concat(dllPackages)
93
- };
94
- }
95
- getBobDllDependencies() {
96
- let dependencies = [];
97
- if (typeof this.bob.dllPackages === 'undefined')
98
- return dependencies;
99
- this.bob.dllPackages.forEach((dependency) => {
100
- dependencies.push(new DllReferencePlugin({
101
- name: dependency.name,
102
- manifest: dependency.manifest
103
- }));
104
- });
105
- return dependencies;
106
- }
107
- getCSSFileName() {
108
- if (this.hash === false
109
- || typeof this.hash.css !== 'undefined'
110
- && this.hash.css === false) {
111
- return 'style.css';
112
- }
113
- return 'style.[hash].css';
114
- }
115
- }
116
- exports.Configuration = Configuration;
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ var entry_1 = require("./entry");
4
+ var output_1 = require("./output");
5
+ var plugins_1 = require("./plugins");
6
+ var module_1 = require("./module");
7
+ var preset_1 = require("../enums/preset");
8
+ var vue_typescript_preset_1 = require("../presets/vue-typescript.preset");
9
+ var typescript_preset_1 = require("../presets/typescript.preset");
10
+ var javascript_preset_1 = require("../presets/javascript.preset");
11
+ var mode_1 = require("../enums/mode");
12
+ var production_config_1 = require("../defaults/production.config");
13
+ var development_config_1 = require("../defaults/development.config");
14
+ var ManifestGenerator = require("@studyportals/bob-manifest-generator").ManifestGenerator;
15
+ var DllReferencePlugin = require("@studyportals/bob-manifest-generator").DllReferencePlugin;
16
+ var merge = require("webpack-merge");
17
+ var Configuration = /** @class */ (function () {
18
+ function Configuration(options) {
19
+ var _a;
20
+ this.bob = options.bob || null;
21
+ this.entry = new entry_1.Entry(options.entry);
22
+ this.output = new output_1.Output(options.output);
23
+ this.extensions = options.extensions || [];
24
+ this.preset = options.preset || null;
25
+ this.hash = options.output.hash || false;
26
+ this.plugins = new plugins_1.Plugins(options.plugins);
27
+ this.module = new module_1.Module(options.module);
28
+ this.commonConfig = options.common || {};
29
+ this.environmentSpecificConfig = (_a = {},
30
+ _a[mode_1.Mode.DEVELOPMENT] = merge([options[mode_1.Mode.DEVELOPMENT], development_config_1.DevelopmentConfig]) || development_config_1.DevelopmentConfig,
31
+ _a[mode_1.Mode.PRODUCTION] = merge([options[mode_1.Mode.PRODUCTION], production_config_1.ProductionConfig(this.bob)]) || production_config_1.ProductionConfig(this.bob),
32
+ _a);
33
+ this.detectPresets();
34
+ }
35
+ Configuration.prototype.get = function (mode) {
36
+ return merge({
37
+ entry: this.entry.getEntry(),
38
+ output: this.output.getOutput(),
39
+ plugins: this.plugins.getPlugins(),
40
+ module: this.module.getModule(),
41
+ resolve: {
42
+ extensions: this.extensions
43
+ },
44
+ performance: {
45
+ hints: false
46
+ },
47
+ optimization: {
48
+ minimize: false
49
+ },
50
+ devtool: 'source-map'
51
+ }, this.getBobConfig(), this.commonConfig, this.getEnvironmentSpecificConfig(mode), { mode: mode });
52
+ };
53
+ Configuration.prototype.detectPresets = function () {
54
+ switch (this.preset) {
55
+ case preset_1.Preset.VUE_TYPESCRIPT:
56
+ this.injectPreset(new vue_typescript_preset_1.VueTypeScriptPreset());
57
+ break;
58
+ case preset_1.Preset.TYPESCRIPT:
59
+ this.injectPreset(new typescript_preset_1.TypeScriptPreset());
60
+ break;
61
+ case preset_1.Preset.JAVASCRIPT:
62
+ this.injectPreset(new javascript_preset_1.JavascriptPreset());
63
+ break;
64
+ default:
65
+ break;
66
+ }
67
+ };
68
+ Configuration.prototype.injectPreset = function (preset) {
69
+ var _this = this;
70
+ var plugins = preset.getPlugins(this.getCSSFileName());
71
+ var module = preset.getModule();
72
+ plugins.forEach(function (plugin) {
73
+ _this.plugins.addPlugin(plugin);
74
+ });
75
+ this.extensions = this.extensions.concat(preset.getExtensions());
76
+ this.module.setModule(module);
77
+ };
78
+ Configuration.prototype.getEnvironmentSpecificConfig = function (mode) {
79
+ return this.environmentSpecificConfig[mode];
80
+ };
81
+ Configuration.prototype.getBobConfig = function () {
82
+ if (this.bob === null) {
83
+ return {};
84
+ }
85
+ var dllPackages = [];
86
+ if (typeof this.bob.dllPackages !== 'undefined'
87
+ && this.bob.dllPackages.length > 0) {
88
+ dllPackages = this.getBobDllDependencies();
89
+ delete this.bob.dllPackages;
90
+ }
91
+ return {
92
+ plugins: [
93
+ new ManifestGenerator(this.bob)
94
+ ].concat(dllPackages)
95
+ };
96
+ };
97
+ Configuration.prototype.getBobDllDependencies = function () {
98
+ var dependencies = [];
99
+ if (typeof this.bob.dllPackages === 'undefined')
100
+ return dependencies;
101
+ this.bob.dllPackages.forEach(function (dependency) {
102
+ dependencies.push(new DllReferencePlugin({
103
+ name: dependency.name,
104
+ manifest: dependency.manifest
105
+ }));
106
+ });
107
+ return dependencies;
108
+ };
109
+ Configuration.prototype.getCSSFileName = function () {
110
+ if (this.hash === false
111
+ || typeof this.hash.css !== 'undefined'
112
+ && this.hash.css === false) {
113
+ return 'style.css';
114
+ }
115
+ return 'style.[hash].css';
116
+ };
117
+ return Configuration;
118
+ }());
119
+ exports.Configuration = Configuration;
@@ -1,11 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class Entry {
4
- constructor(entry) {
5
- this.entry = entry;
6
- }
7
- getEntry() {
8
- return this.entry;
9
- }
10
- }
11
- exports.Entry = Entry;
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ var Entry = /** @class */ (function () {
4
+ function Entry(entry) {
5
+ this.entry = entry;
6
+ }
7
+ Entry.prototype.getEntry = function () {
8
+ return this.entry;
9
+ };
10
+ return Entry;
11
+ }());
12
+ exports.Entry = Entry;
@@ -1,16 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const merge = require("webpack-merge");
4
- class Module {
5
- constructor(module = {}) {
6
- this.module = {};
7
- this.module = merge(this.module, module);
8
- }
9
- setModule(module) {
10
- this.module = merge(this.module, module);
11
- }
12
- getModule() {
13
- return this.module;
14
- }
15
- }
16
- exports.Module = Module;
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ var merge = require("webpack-merge");
4
+ var Module = /** @class */ (function () {
5
+ function Module(module) {
6
+ if (module === void 0) { module = {}; }
7
+ this.module = {};
8
+ this.module = merge(this.module, module);
9
+ }
10
+ Module.prototype.setModule = function (module) {
11
+ this.module = merge(this.module, module);
12
+ };
13
+ Module.prototype.getModule = function () {
14
+ return this.module;
15
+ };
16
+ return Module;
17
+ }());
18
+ exports.Module = Module;
@@ -1,44 +1,45 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class Output {
4
- constructor(outputConfig) {
5
- this.path = outputConfig.path;
6
- this.publicPath = outputConfig.publicPath || null;
7
- this.library = outputConfig.library || null;
8
- this.addHash = this.shouldAddHash(outputConfig.hash),
9
- this.fileName = outputConfig.fileName || "[name]";
10
- this.crossOriginLoading = outputConfig.crossOriginLoading || null;
11
- }
12
- getOutput() {
13
- let output = {
14
- path: this.path,
15
- filename: this.getFileName()
16
- };
17
- if (this.publicPath !== null) {
18
- output.publicPath = this.publicPath;
19
- }
20
- if (this.library !== null) {
21
- output.library = this.library;
22
- }
23
- if (this.crossOriginLoading !== null) {
24
- output.crossOriginLoading = this.crossOriginLoading;
25
- }
26
- return output;
27
- }
28
- getFileName() {
29
- let fileName = this.addHash === true ? `${this.fileName}.[hash].js` : `${this.fileName}.js`;
30
- return fileName;
31
- }
32
- shouldAddHash(hashConfig) {
33
- if (typeof hashConfig === 'undefined') {
34
- return true;
35
- }
36
- if (typeof hashConfig.js !== 'undefined'
37
- && hashConfig.js === false
38
- || hashConfig === false) {
39
- return false;
40
- }
41
- return true;
42
- }
43
- }
44
- exports.Output = Output;
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ var Output = /** @class */ (function () {
4
+ function Output(outputConfig) {
5
+ this.path = outputConfig.path;
6
+ this.publicPath = outputConfig.publicPath || null;
7
+ this.library = outputConfig.library || null;
8
+ this.addHash = this.shouldAddHash(outputConfig.hash),
9
+ this.fileName = outputConfig.fileName || "[name]";
10
+ this.crossOriginLoading = outputConfig.crossOriginLoading || null;
11
+ }
12
+ Output.prototype.getOutput = function () {
13
+ var output = {
14
+ path: this.path,
15
+ filename: this.getFileName()
16
+ };
17
+ if (this.publicPath !== null) {
18
+ output.publicPath = this.publicPath;
19
+ }
20
+ if (this.library !== null) {
21
+ output.library = this.library;
22
+ }
23
+ if (this.crossOriginLoading !== null) {
24
+ output.crossOriginLoading = this.crossOriginLoading;
25
+ }
26
+ return output;
27
+ };
28
+ Output.prototype.getFileName = function () {
29
+ var fileName = this.addHash === true ? this.fileName + ".[hash].js" : this.fileName + ".js";
30
+ return fileName;
31
+ };
32
+ Output.prototype.shouldAddHash = function (hashConfig) {
33
+ if (typeof hashConfig === 'undefined') {
34
+ return true;
35
+ }
36
+ if (typeof hashConfig.js !== 'undefined'
37
+ && hashConfig.js === false
38
+ || hashConfig === false) {
39
+ return false;
40
+ }
41
+ return true;
42
+ };
43
+ return Output;
44
+ }());
45
+ exports.Output = Output;
@@ -1,15 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class Plugins {
4
- constructor(plugins = []) {
5
- this.plugins = [];
6
- this.plugins = this.plugins.concat(plugins);
7
- }
8
- addPlugin(plugin) {
9
- this.plugins.push(plugin);
10
- }
11
- getPlugins() {
12
- return this.plugins;
13
- }
14
- }
15
- exports.Plugins = Plugins;
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ var Plugins = /** @class */ (function () {
4
+ function Plugins(plugins) {
5
+ if (plugins === void 0) { plugins = []; }
6
+ this.plugins = [];
7
+ this.plugins = this.plugins.concat(plugins);
8
+ }
9
+ Plugins.prototype.addPlugin = function (plugin) {
10
+ this.plugins.push(plugin);
11
+ };
12
+ Plugins.prototype.getPlugins = function () {
13
+ return this.plugins;
14
+ };
15
+ return Plugins;
16
+ }());
17
+ exports.Plugins = Plugins;