@studyportals/webpack-helper 2.5.0-beta.0 → 2.5.0-beta.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studyportals/webpack-helper",
3
- "version": "2.5.0-beta.0",
3
+ "version": "2.5.0-beta.1",
4
4
  "description": "A collection of standard configurations and helpers for webpack.",
5
5
  "main": "src/main.js",
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DevelopmentConfig = {
4
4
  optimization: {
5
5
  minimize: false
@@ -1,13 +1,13 @@
1
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'];
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
9
  if (bobConfig !== null && bobConfig.hasOwnProperty('dllPackages')) {
10
- bobConfig.dllPackages.forEach(function (dependency) { return dllDependencies.push(dependency.manifest.name); });
10
+ bobConfig.dllPackages.forEach((dependency) => dllDependencies.push(dependency.manifest.name));
11
11
  }
12
12
  return {
13
13
  plugins: [
@@ -29,7 +29,7 @@ exports.ProductionConfig = function (bobConfig) {
29
29
  }
30
30
  }
31
31
  ]
32
- }
32
+ },
33
33
  }),
34
34
  new DllAvailabilityTracker({
35
35
  dependencies: dllDependencies || []
package/src/enums/mode.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var Mode;
4
4
  (function (Mode) {
5
5
  Mode["DEVELOPMENT"] = "development";
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var Preset;
4
4
  (function (Preset) {
5
5
  Preset["VUE_TYPESCRIPT"] = "vue-typescript";
@@ -1,12 +1,9 @@
1
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) {
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const configuration_1 = require("../model/configuration");
4
+ class ConfigurationFactory {
5
+ create(options) {
8
6
  return new configuration_1.Configuration(options);
9
- };
10
- return ConfigurationFactory;
11
- }());
7
+ }
8
+ }
12
9
  exports.ConfigurationFactory = ConfigurationFactory;
@@ -1,2 +1,2 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,2 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,2 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,2 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,2 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/src/main.js ADDED
@@ -0,0 +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,22 +1,21 @@
1
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;
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) {
20
19
  this.bob = options.bob || null;
21
20
  this.entry = new entry_1.Entry(options.entry);
22
21
  this.output = new output_1.Output(options.output);
@@ -26,13 +25,13 @@ var Configuration = /** @class */ (function () {
26
25
  this.plugins = new plugins_1.Plugins(options.plugins);
27
26
  this.module = new module_1.Module(options.module);
28
27
  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);
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
+ };
33
32
  this.detectPresets();
34
33
  }
35
- Configuration.prototype.get = function (mode) {
34
+ get(mode) {
36
35
  return merge({
37
36
  entry: this.entry.getEntry(),
38
37
  output: this.output.getOutput(),
@@ -48,9 +47,9 @@ var Configuration = /** @class */ (function () {
48
47
  minimize: false
49
48
  },
50
49
  devtool: 'source-map'
51
- }, this.getBobConfig(), this.commonConfig, this.getEnvironmentSpecificConfig(mode), { mode: mode });
52
- };
53
- Configuration.prototype.detectPresets = function () {
50
+ }, this.getBobConfig(), this.commonConfig, this.getEnvironmentSpecificConfig(mode), { mode });
51
+ }
52
+ detectPresets() {
54
53
  switch (this.preset) {
55
54
  case preset_1.Preset.VUE_TYPESCRIPT:
56
55
  this.injectPreset(new vue_typescript_preset_1.VueTypeScriptPreset());
@@ -64,25 +63,24 @@ var Configuration = /** @class */ (function () {
64
63
  default:
65
64
  break;
66
65
  }
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);
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);
74
72
  });
75
73
  this.extensions = this.extensions.concat(preset.getExtensions());
76
74
  this.module.setModule(module);
77
- };
78
- Configuration.prototype.getEnvironmentSpecificConfig = function (mode) {
75
+ }
76
+ getEnvironmentSpecificConfig(mode) {
79
77
  return this.environmentSpecificConfig[mode];
80
- };
81
- Configuration.prototype.getBobConfig = function () {
78
+ }
79
+ getBobConfig() {
82
80
  if (this.bob === null) {
83
81
  return {};
84
82
  }
85
- var dllPackages = [];
83
+ let dllPackages = [];
86
84
  if (typeof this.bob.dllPackages !== 'undefined'
87
85
  && this.bob.dllPackages.length > 0) {
88
86
  dllPackages = this.getBobDllDependencies();
@@ -93,27 +91,26 @@ var Configuration = /** @class */ (function () {
93
91
  new ManifestGenerator(this.bob)
94
92
  ].concat(dllPackages)
95
93
  };
96
- };
97
- Configuration.prototype.getBobDllDependencies = function () {
98
- var dependencies = [];
94
+ }
95
+ getBobDllDependencies() {
96
+ let dependencies = [];
99
97
  if (typeof this.bob.dllPackages === 'undefined')
100
98
  return dependencies;
101
- this.bob.dllPackages.forEach(function (dependency) {
99
+ this.bob.dllPackages.forEach((dependency) => {
102
100
  dependencies.push(new DllReferencePlugin({
103
101
  name: dependency.name,
104
102
  manifest: dependency.manifest
105
103
  }));
106
104
  });
107
105
  return dependencies;
108
- };
109
- Configuration.prototype.getCSSFileName = function () {
106
+ }
107
+ getCSSFileName() {
110
108
  if (this.hash === false
111
109
  || typeof this.hash.css !== 'undefined'
112
110
  && this.hash.css === false) {
113
111
  return 'style.css';
114
112
  }
115
113
  return 'style.[hash].css';
116
- };
117
- return Configuration;
118
- }());
114
+ }
115
+ }
119
116
  exports.Configuration = Configuration;
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
- exports.__esModule = true;
3
- var Entry = /** @class */ (function () {
4
- function Entry(entry) {
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Entry {
4
+ constructor(entry) {
5
5
  this.entry = entry;
6
6
  }
7
- Entry.prototype.getEntry = function () {
7
+ getEntry() {
8
8
  return this.entry;
9
- };
10
- return Entry;
11
- }());
9
+ }
10
+ }
12
11
  exports.Entry = Entry;
@@ -1,18 +1,16 @@
1
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 = {}; }
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const merge = require("webpack-merge");
4
+ class Module {
5
+ constructor(module = {}) {
7
6
  this.module = {};
8
7
  this.module = merge(this.module, module);
9
8
  }
10
- Module.prototype.setModule = function (module) {
9
+ setModule(module) {
11
10
  this.module = merge(this.module, module);
12
- };
13
- Module.prototype.getModule = function () {
11
+ }
12
+ getModule() {
14
13
  return this.module;
15
- };
16
- return Module;
17
- }());
14
+ }
15
+ }
18
16
  exports.Module = Module;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
- exports.__esModule = true;
3
- var Output = /** @class */ (function () {
4
- function Output(outputConfig) {
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Output {
4
+ constructor(outputConfig) {
5
5
  this.path = outputConfig.path;
6
6
  this.publicPath = outputConfig.publicPath || null;
7
7
  this.library = outputConfig.library || null;
@@ -9,8 +9,8 @@ var Output = /** @class */ (function () {
9
9
  this.fileName = outputConfig.fileName || "[name]";
10
10
  this.crossOriginLoading = outputConfig.crossOriginLoading || null;
11
11
  }
12
- Output.prototype.getOutput = function () {
13
- var output = {
12
+ getOutput() {
13
+ let output = {
14
14
  path: this.path,
15
15
  filename: this.getFileName()
16
16
  };
@@ -24,12 +24,12 @@ var Output = /** @class */ (function () {
24
24
  output.crossOriginLoading = this.crossOriginLoading;
25
25
  }
26
26
  return output;
27
- };
28
- Output.prototype.getFileName = function () {
29
- var fileName = this.addHash === true ? this.fileName + ".[hash].js" : this.fileName + ".js";
27
+ }
28
+ getFileName() {
29
+ let fileName = this.addHash === true ? `${this.fileName}.[hash].js` : `${this.fileName}.js`;
30
30
  return fileName;
31
- };
32
- Output.prototype.shouldAddHash = function (hashConfig) {
31
+ }
32
+ shouldAddHash(hashConfig) {
33
33
  if (typeof hashConfig === 'undefined') {
34
34
  return true;
35
35
  }
@@ -39,7 +39,6 @@ var Output = /** @class */ (function () {
39
39
  return false;
40
40
  }
41
41
  return true;
42
- };
43
- return Output;
44
- }());
42
+ }
43
+ }
45
44
  exports.Output = Output;
@@ -1,17 +1,15 @@
1
1
  "use strict";
2
- exports.__esModule = true;
3
- var Plugins = /** @class */ (function () {
4
- function Plugins(plugins) {
5
- if (plugins === void 0) { plugins = []; }
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Plugins {
4
+ constructor(plugins = []) {
6
5
  this.plugins = [];
7
6
  this.plugins = this.plugins.concat(plugins);
8
7
  }
9
- Plugins.prototype.addPlugin = function (plugin) {
8
+ addPlugin(plugin) {
10
9
  this.plugins.push(plugin);
11
- };
12
- Plugins.prototype.getPlugins = function () {
10
+ }
11
+ getPlugins() {
13
12
  return this.plugins;
14
- };
15
- return Plugins;
16
- }());
13
+ }
14
+ }
17
15
  exports.Plugins = Plugins;
@@ -1,17 +1,15 @@
1
1
  "use strict";
2
- exports.__esModule = true;
3
- var MiniCssExtractPlugin = require('mini-css-extract-plugin');
4
- var JavascriptPreset = /** @class */ (function () {
5
- function JavascriptPreset() {
6
- }
7
- JavascriptPreset.prototype.getPlugins = function (filename) {
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
4
+ class JavascriptPreset {
5
+ getPlugins(filename) {
8
6
  return [
9
7
  new MiniCssExtractPlugin({
10
- filename: filename
8
+ filename
11
9
  })
12
10
  ];
13
- };
14
- JavascriptPreset.prototype.getModule = function () {
11
+ }
12
+ getModule() {
15
13
  return {
16
14
  rules: [
17
15
  {
@@ -19,7 +17,7 @@ var JavascriptPreset = /** @class */ (function () {
19
17
  use: [
20
18
  MiniCssExtractPlugin.loader,
21
19
  'css-loader'
22
- ]
20
+ ],
23
21
  },
24
22
  {
25
23
  test: /\.scss$/,
@@ -27,7 +25,7 @@ var JavascriptPreset = /** @class */ (function () {
27
25
  MiniCssExtractPlugin.loader,
28
26
  'css-loader',
29
27
  'sass-loader'
30
- ]
28
+ ],
31
29
  },
32
30
  {
33
31
  test: /\.jsx?$/,
@@ -36,14 +34,13 @@ var JavascriptPreset = /** @class */ (function () {
36
34
  }
37
35
  ]
38
36
  };
39
- };
40
- JavascriptPreset.prototype.getExtensions = function () {
37
+ }
38
+ getExtensions() {
41
39
  return [
42
40
  '*',
43
41
  '.js',
44
42
  '.json'
45
43
  ];
46
- };
47
- return JavascriptPreset;
48
- }());
44
+ }
45
+ }
49
46
  exports.JavascriptPreset = JavascriptPreset;
@@ -1,17 +1,15 @@
1
1
  "use strict";
2
- exports.__esModule = true;
3
- var MiniCssExtractPlugin = require('mini-css-extract-plugin');
4
- var TypeScriptPreset = /** @class */ (function () {
5
- function TypeScriptPreset() {
6
- }
7
- TypeScriptPreset.prototype.getPlugins = function (filename) {
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
4
+ class TypeScriptPreset {
5
+ getPlugins(filename) {
8
6
  return [
9
7
  new MiniCssExtractPlugin({
10
- filename: filename
8
+ filename
11
9
  })
12
10
  ];
13
- };
14
- TypeScriptPreset.prototype.getModule = function () {
11
+ }
12
+ getModule() {
15
13
  return {
16
14
  rules: [
17
15
  {
@@ -19,7 +17,7 @@ var TypeScriptPreset = /** @class */ (function () {
19
17
  use: [
20
18
  MiniCssExtractPlugin.loader,
21
19
  'css-loader'
22
- ]
20
+ ],
23
21
  },
24
22
  {
25
23
  test: /\.scss$/,
@@ -27,7 +25,7 @@ var TypeScriptPreset = /** @class */ (function () {
27
25
  MiniCssExtractPlugin.loader,
28
26
  'css-loader',
29
27
  'sass-loader'
30
- ]
28
+ ],
31
29
  },
32
30
  {
33
31
  test: /\.tsx?$/,
@@ -48,15 +46,14 @@ var TypeScriptPreset = /** @class */ (function () {
48
46
  }
49
47
  ]
50
48
  };
51
- };
52
- TypeScriptPreset.prototype.getExtensions = function () {
49
+ }
50
+ getExtensions() {
53
51
  return [
54
52
  '*',
55
53
  '.ts',
56
54
  '.js',
57
55
  '.json'
58
56
  ];
59
- };
60
- return TypeScriptPreset;
61
- }());
57
+ }
58
+ }
62
59
  exports.TypeScriptPreset = TypeScriptPreset;
@@ -1,23 +1,21 @@
1
1
  "use strict";
2
- exports.__esModule = true;
3
- var webpack = require("webpack");
4
- var MiniCssExtractPlugin = require('mini-css-extract-plugin');
5
- var VueLoaderPlugin = require('vue-loader').VueLoaderPlugin;
6
- var VueTypeScriptPreset = /** @class */ (function () {
7
- function VueTypeScriptPreset() {
8
- }
9
- VueTypeScriptPreset.prototype.getPlugins = function (filename) {
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const webpack = require("webpack");
4
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
5
+ const VueLoaderPlugin = require('vue-loader').VueLoaderPlugin;
6
+ class VueTypeScriptPreset {
7
+ getPlugins(filename) {
10
8
  return [
11
9
  new webpack.DllReferencePlugin({
12
10
  manifest: require("@studyportals/vue-config/dist/library.json")
13
11
  }),
14
12
  new MiniCssExtractPlugin({
15
- filename: filename
13
+ filename
16
14
  }),
17
15
  new VueLoaderPlugin()
18
16
  ];
19
- };
20
- VueTypeScriptPreset.prototype.getModule = function () {
17
+ }
18
+ getModule() {
21
19
  return {
22
20
  rules: [
23
21
  {
@@ -25,7 +23,7 @@ var VueTypeScriptPreset = /** @class */ (function () {
25
23
  use: [
26
24
  MiniCssExtractPlugin.loader,
27
25
  'css-loader'
28
- ]
26
+ ],
29
27
  },
30
28
  {
31
29
  test: /\.scss$/,
@@ -33,7 +31,7 @@ var VueTypeScriptPreset = /** @class */ (function () {
33
31
  MiniCssExtractPlugin.loader,
34
32
  'css-loader',
35
33
  'sass-loader'
36
- ]
34
+ ],
37
35
  },
38
36
  {
39
37
  test: /\.vue$/,
@@ -54,7 +52,7 @@ var VueTypeScriptPreset = /** @class */ (function () {
54
52
  exclude: /node_modules\/(?!@studyportals\/).*/,
55
53
  options: {
56
54
  appendTsSuffixTo: [/\.vue$/]
57
- }
55
+ },
58
56
  },
59
57
  {
60
58
  test: /\.js$/,
@@ -70,8 +68,8 @@ var VueTypeScriptPreset = /** @class */ (function () {
70
68
  },
71
69
  ]
72
70
  };
73
- };
74
- VueTypeScriptPreset.prototype.getExtensions = function () {
71
+ }
72
+ getExtensions() {
75
73
  return [
76
74
  '*',
77
75
  '.ts',
@@ -79,7 +77,6 @@ var VueTypeScriptPreset = /** @class */ (function () {
79
77
  '.vue',
80
78
  '.json'
81
79
  ];
82
- };
83
- return VueTypeScriptPreset;
84
- }());
80
+ }
81
+ }
85
82
  exports.VueTypeScriptPreset = VueTypeScriptPreset;