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