Skip to content

Commit 0443814

Browse files
committed
feature(webpack4) Use redirect-webpack-plugin
1 parent 4a3f87a commit 0443814

File tree

4 files changed

+32
-45
lines changed

4 files changed

+32
-45
lines changed

antwar.config.js

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,49 +19,7 @@ module.exports = () => ({
1919
redirects: {
2020
'support': '/contribute',
2121
'writers-guide': '/contribute/writers-guide'
22-
},
23-
paths: {
24-
25-
/*************************
26-
Redirects for Old Content
27-
*************************/
28-
'get-started': {
29-
hidden: true,
30-
redirects: {
31-
'': '/guides/getting-started',
32-
'install-webpack': '/guides/installation',
33-
'why-webpack': '/guides/why-webpack',
34-
}
35-
},
36-
pluginsapi: {
37-
hidden: true,
38-
redirects: {
39-
'': '/api/plugins',
40-
'compiler': '/api/compiler',
41-
'template': '/api/template'
42-
}
43-
},
44-
'api/plugins': {
45-
redirects: {
46-
'compiler': '/api/compiler',
47-
'compilation': '/api/compilation',
48-
'module-factories': '/api/module-factories',
49-
'parser': '/api/parser',
50-
'tapable': '/api/tapable',
51-
'template': '/api/template',
52-
'resolver': '/api/resolver'
53-
}
54-
},
55-
development: {
56-
redirects: {
57-
'': '/contribute',
58-
'plugin-patterns': '/contribute/plugin-patterns',
59-
'release-process': '/contribute/release-process',
60-
'how-to-write-a-loader': '/contribute/writing-a-loader',
61-
'how-to-write-a-plugin': '/contribute/writing-a-plugin'
62-
}
63-
}
64-
}
22+
}
6523
},
6624
concepts: {
6725
title: 'Concepts',

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
"prism-languages": "^0.3.3",
8585
"prismjs": "^1.9.0",
8686
"raw-loader": "^0.5.1",
87+
"redirect-webpack-plugin": "^0.1.1",
8788
"request": "^2.81.0",
8889
"sass-loader": "^6.0.6",
8990
"sitemap-static": "^0.4.2",

webpack.config.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const path = require('path');
22
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
33
const CopyWebpackPlugin = require('copy-webpack-plugin');
4+
const RedirectWebpackPlugin = require('redirect-webpack-plugin');
45

56
const cwd = process.cwd();
67

@@ -95,9 +96,30 @@ module.exports = (env) => ({
9596
from: './src/assets',
9697
to: './assets'
9798
}]),
98-
9999
new MiniCssExtractPlugin({
100100
filename: '[chunkhash].css'
101-
})
101+
}),
102+
new RedirectWebpackPlugin({
103+
redirects: {
104+
'get-started': '/guides/getting-started/',
105+
'get-started/install-webpack': '/guides/installation/',
106+
'get-started/why-webpack': '/guides/why-webpack/',
107+
'pluginsapi': '/api/plugins/',
108+
'pluginsapi/compiler': '/api/compiler/',
109+
'pluginsapi/template': '/api/template/',
110+
'api/plugins/compiler': '/api/compiler/',
111+
'api/plugins/compilation': '/api/compilation/',
112+
'api/plugins/module-factories': '/api/module-factories/',
113+
'api/plugins/parser': '/api/parser/',
114+
'api/plugins/tapable': '/api/tapable/',
115+
'api/plugins/template': '/api/template/',
116+
'api/plugins/resolver': '/api/resolver/',
117+
'development': '/contribute/',
118+
'development/plugin-patterns': '/contribute/plugin-patterns/',
119+
'development/release-process': '/contribute/release-process/',
120+
'development/how-to-write-a-loader': '/contribute/writing-a-loader/',
121+
'development/how-to-write-a-plugin': '/contribute/writing-a-plugin/',
122+
},
123+
}),
102124
]
103125
});

yarn.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6219,6 +6219,12 @@ redent@^1.0.0:
62196219
indent-string "^2.1.0"
62206220
strip-indent "^1.0.1"
62216221

6222+
redirect-webpack-plugin@^0.1.1:
6223+
version "0.1.1"
6224+
resolved "https://registry.yarnpkg.com/redirect-webpack-plugin/-/redirect-webpack-plugin-0.1.1.tgz#37de577dc230e05edc1ab68d2416644dea1f552a"
6225+
dependencies:
6226+
webpack-sources "^1.1.0"
6227+
62226228
reduce-css-calc@^1.2.6:
62236229
version "1.3.0"
62246230
resolved "https://registry.yarnpkg.com/reduce-css-calc/-/reduce-css-calc-1.3.0.tgz#747c914e049614a4c9cfbba629871ad1d2927716"

0 commit comments

Comments
 (0)