@studyportals/webpack-helper 3.0.0-beta.8 → 3.0.1-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.
package/README.md
CHANGED
|
@@ -4,6 +4,7 @@ WebpackHelper is a utility that makes it easy to set up a webpack configuration
|
|
|
4
4
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
- [Webpack version](#webpack-version)
|
|
7
|
+
- [Notes on updating Webpack from v4 to v5](#notes-on-updating-webpack-from-v4-to-v5)
|
|
7
8
|
- [Quick Start](#quick-start)
|
|
8
9
|
- [Configuration](#configuration)
|
|
9
10
|
- [entry](#entry-required)
|
|
@@ -22,6 +23,50 @@ WebpackHelper is a utility that makes it easy to set up a webpack configuration
|
|
|
22
23
|
## Webpack version
|
|
23
24
|
This version of WebpackHelper is based on webpack 5. Some earlier WebpackHelper versions used earlier versions of Webpack. If you get syntax errors when updating to the latest version of WebpackHelper, please check out the [Webpack documentation](https://webpack.js.org/configuration/).
|
|
24
25
|
|
|
26
|
+
### Notes on updating Webpack from v4 to v5
|
|
27
|
+
Below are some notes that might be helpful when you're upgrading a microservice from webpack-helper v2 (based on Webpack v4) to v3 (based on Webpack v5).
|
|
28
|
+
|
|
29
|
+
#### Dev server
|
|
30
|
+
Webpack-helper **v2 and below**: Your `development.devServer` file might include these parts:
|
|
31
|
+
```javascript
|
|
32
|
+
{
|
|
33
|
+
development: {
|
|
34
|
+
devServer: {
|
|
35
|
+
open: true,
|
|
36
|
+
overlay: true,
|
|
37
|
+
writeToDisk: true
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
Webpack-helper **v3 and beyond**: Your `webpack.config.js` file should configure those parts like this:
|
|
43
|
+
```javascript
|
|
44
|
+
{
|
|
45
|
+
development: {
|
|
46
|
+
devServer: {
|
|
47
|
+
client: {
|
|
48
|
+
overlay: true
|
|
49
|
+
},
|
|
50
|
+
devMiddleware: {
|
|
51
|
+
writeToDisk: true
|
|
52
|
+
},
|
|
53
|
+
open: true,
|
|
54
|
+
static: path.join(__dirname, '.') // Related to writeToDisk.
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### Exporting
|
|
61
|
+
Webpack-helper **v2 and below**: Your `webpack.config.js` file ended with the following:
|
|
62
|
+
```javascript
|
|
63
|
+
module.exports = mode => configuration.get(mode);
|
|
64
|
+
```
|
|
65
|
+
Webpack-helper **v3 and beyond**: Your `webpack.config.js` file should end with the following (as is also mentioned further below):
|
|
66
|
+
```javascript
|
|
67
|
+
module.exports = (env, details) => configuration.get(details.mode);
|
|
68
|
+
```
|
|
69
|
+
|
|
25
70
|
## Quick Start
|
|
26
71
|
|
|
27
72
|
```bash
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studyportals/webpack-helper",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1-beta.0",
|
|
4
4
|
"description": "A collection of standard configurations and helpers for webpack.",
|
|
5
5
|
"main": "src/main.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "jest --coverage",
|
|
8
8
|
"build": "tsc",
|
|
9
|
-
"prepublish": "npm run build"
|
|
10
|
-
"postinstall": "cp ./assets/.babelrc ./assets/.browserslistrc ../../../"
|
|
9
|
+
"prepublish": "npm run build"
|
|
11
10
|
},
|
|
12
11
|
"files": [
|
|
13
12
|
"src/**/*.js",
|
|
@@ -28,10 +27,10 @@
|
|
|
28
27
|
"@babel/preset-env": "^7.5.5",
|
|
29
28
|
"@babel/preset-typescript": "^7.3.3",
|
|
30
29
|
"@babel/runtime": "^7.5.5",
|
|
31
|
-
"@studyportals/bob-manifest-generator": "^
|
|
30
|
+
"@studyportals/bob-manifest-generator": "^3.0.0",
|
|
32
31
|
"@studyportals/browserslist-config": "^1.2.0",
|
|
33
|
-
"@studyportals/dll-availability-tracker": "^
|
|
34
|
-
"@studyportals/vue-config": "4.0.0
|
|
32
|
+
"@studyportals/dll-availability-tracker": "^2.0.0",
|
|
33
|
+
"@studyportals/vue-config": "^4.0.0",
|
|
35
34
|
"babel-loader": "^8.2.3",
|
|
36
35
|
"css-loader": "^6.5.1",
|
|
37
36
|
"file-loader": "^6.2.0",
|
|
@@ -26,13 +26,15 @@ class Configuration {
|
|
|
26
26
|
this.plugins = new plugins_1.Plugins(options.plugins);
|
|
27
27
|
this.module = new module_1.Module(options.module);
|
|
28
28
|
this.commonConfig = options.common || {};
|
|
29
|
+
const configDev = options[mode_1.Mode.DEVELOPMENT] ? options[mode_1.Mode.DEVELOPMENT] : {};
|
|
30
|
+
const configPrd = options[mode_1.Mode.PRODUCTION] ? options[mode_1.Mode.PRODUCTION] : {};
|
|
29
31
|
this.environmentSpecificConfig = {
|
|
30
|
-
[mode_1.Mode.DEVELOPMENT]: merge([
|
|
31
|
-
[mode_1.Mode.PRODUCTION]: merge([
|
|
32
|
+
[mode_1.Mode.DEVELOPMENT]: merge([configDev, development_config_1.DevelopmentConfig]) || development_config_1.DevelopmentConfig,
|
|
33
|
+
[mode_1.Mode.PRODUCTION]: merge([configPrd, production_config_1.ProductionConfig(this.bob)]) || production_config_1.ProductionConfig(this.bob)
|
|
32
34
|
};
|
|
33
|
-
this.detectPresets();
|
|
34
35
|
}
|
|
35
36
|
get(mode) {
|
|
37
|
+
this.detectPresets(mode);
|
|
36
38
|
return merge({
|
|
37
39
|
entry: this.entry.getEntry(),
|
|
38
40
|
output: this.output.getOutput(),
|
|
@@ -50,10 +52,10 @@ class Configuration {
|
|
|
50
52
|
devtool: 'source-map'
|
|
51
53
|
}, this.getBobConfig(), this.commonConfig, this.getEnvironmentSpecificConfig(mode), { mode });
|
|
52
54
|
}
|
|
53
|
-
detectPresets() {
|
|
55
|
+
detectPresets(mode) {
|
|
54
56
|
switch (this.preset) {
|
|
55
57
|
case preset_1.Preset.VUE_TYPESCRIPT:
|
|
56
|
-
this.injectPreset(new vue_typescript_preset_1.VueTypeScriptPreset());
|
|
58
|
+
this.injectPreset(new vue_typescript_preset_1.VueTypeScriptPreset(mode));
|
|
57
59
|
break;
|
|
58
60
|
case preset_1.Preset.TYPESCRIPT:
|
|
59
61
|
this.injectPreset(new typescript_preset_1.TypeScriptPreset());
|
package/src/model/output.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.Output = void 0;
|
|
|
4
4
|
class Output {
|
|
5
5
|
constructor(outputConfig) {
|
|
6
6
|
this.path = outputConfig.path;
|
|
7
|
-
this.publicPath = outputConfig.publicPath
|
|
7
|
+
this.publicPath = typeof outputConfig.publicPath === "string" ? outputConfig.publicPath : null;
|
|
8
8
|
this.library = outputConfig.library || null;
|
|
9
9
|
this.addHash = this.shouldAddHash(outputConfig.hash),
|
|
10
10
|
this.fileName = outputConfig.fileName || "[name]";
|
|
@@ -30,13 +30,24 @@ class TypeScriptPreset {
|
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
test: /\.tsx?$/,
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
exclude: /node_modules\/(?!@studyportals\/).*/,
|
|
34
|
+
use: [
|
|
35
|
+
{
|
|
36
|
+
loader: 'babel-loader',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
loader: 'ts-loader'
|
|
40
|
+
}
|
|
41
|
+
],
|
|
35
42
|
},
|
|
36
43
|
{
|
|
37
44
|
test: /\.js$/,
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
exclude: /node_modules\/(?!@studyportals\/).*/,
|
|
46
|
+
use: [
|
|
47
|
+
{
|
|
48
|
+
loader: 'babel-loader',
|
|
49
|
+
}
|
|
50
|
+
]
|
|
40
51
|
},
|
|
41
52
|
{
|
|
42
53
|
test: /\.(png|jpg|gif|svg)$/,
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VueTypeScriptPreset = void 0;
|
|
4
|
+
const mode_1 = require("../enums/mode");
|
|
4
5
|
const webpack = require("webpack");
|
|
5
6
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
6
7
|
const VueLoaderPlugin = require('vue-loader').VueLoaderPlugin;
|
|
7
8
|
class VueTypeScriptPreset {
|
|
9
|
+
constructor(mode) {
|
|
10
|
+
this.mode = mode;
|
|
11
|
+
}
|
|
8
12
|
getPlugins(filename) {
|
|
9
13
|
return [
|
|
10
14
|
new webpack.DllReferencePlugin({
|
|
11
|
-
manifest: require(
|
|
15
|
+
manifest: require(`@studyportals/vue-config/dist/vue3_library${this.mode === mode_1.Mode.PRODUCTION ? '.min' : ''}.json`)
|
|
12
16
|
}),
|
|
13
17
|
new MiniCssExtractPlugin({
|
|
14
18
|
filename
|
|
@@ -44,16 +48,22 @@ class VueTypeScriptPreset {
|
|
|
44
48
|
'css-loader',
|
|
45
49
|
'sass-loader'
|
|
46
50
|
]
|
|
47
|
-
}
|
|
51
|
+
},
|
|
52
|
+
hotReload: false
|
|
48
53
|
}
|
|
49
54
|
},
|
|
50
55
|
{
|
|
51
56
|
test: /\.tsx?$/,
|
|
52
|
-
loader: 'ts-loader',
|
|
53
57
|
exclude: /node_modules\/(?!@studyportals\/).*/,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
use: [
|
|
59
|
+
{
|
|
60
|
+
loader: 'babel-loader',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
loader: 'ts-loader',
|
|
64
|
+
appendTsSuffixTo: [/\.vue$/]
|
|
65
|
+
}
|
|
66
|
+
],
|
|
57
67
|
},
|
|
58
68
|
{
|
|
59
69
|
test: /\.js$/,
|