@studyportals/webpack-helper 2.5.0 → 2.5.3-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
+ 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
+ };
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
+ 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,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
+ 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,9 +1,9 @@
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
+ 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,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: 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,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
+ 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.fileName = options.output.fileName || "[name]";
33
+ this.detectPresets();
34
+ }
35
+ get(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 });
52
+ }
53
+ detectPresets() {
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
+ injectPreset(preset) {
69
+ const plugins = preset.getPlugins(this.getCSSFileName());
70
+ const module = preset.getModule();
71
+ plugins.forEach(plugin => {
72
+ this.plugins.addPlugin(plugin);
73
+ });
74
+ this.extensions = this.extensions.concat(preset.getExtensions());
75
+ this.module.setModule(module);
76
+ }
77
+ getEnvironmentSpecificConfig(mode) {
78
+ return this.environmentSpecificConfig[mode];
79
+ }
80
+ getBobConfig() {
81
+ if (this.bob === null) {
82
+ return {};
83
+ }
84
+ let dllPackages = [];
85
+ if (typeof this.bob.dllPackages !== 'undefined'
86
+ && this.bob.dllPackages.length > 0) {
87
+ dllPackages = this.getBobDllDependencies();
88
+ delete this.bob.dllPackages;
89
+ }
90
+ return {
91
+ plugins: [
92
+ new ManifestGenerator(this.bob)
93
+ ].concat(dllPackages)
94
+ };
95
+ }
96
+ getBobDllDependencies() {
97
+ let dependencies = [];
98
+ if (typeof this.bob.dllPackages === 'undefined')
99
+ return dependencies;
100
+ this.bob.dllPackages.forEach((dependency) => {
101
+ dependencies.push(new DllReferencePlugin({
102
+ name: dependency.name,
103
+ manifest: dependency.manifest
104
+ }));
105
+ });
106
+ return dependencies;
107
+ }
108
+ getCSSFileName() {
109
+ var _a;
110
+ const fileName = (_a = this.fileName, (_a !== null && _a !== void 0 ? _a : `style`));
111
+ if (this.hash === false
112
+ || typeof this.hash.css !== 'undefined'
113
+ && this.hash.css === false) {
114
+ return `${fileName}.css`;
115
+ }
116
+ return `${fileName}.[fullhash].css`;
117
+ }
118
+ }
119
+ exports.Configuration = Configuration;
@@ -1,11 +1,11 @@
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
+ 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,16 +1,16 @@
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
+ 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,44 +1,44 @@
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
+ 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,15 +1,15 @@
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
+ 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;