Skip to content

Commit 07a2dee

Browse files
committed
feat: upgrade documents
1 parent ee6391b commit 07a2dee

File tree

2 files changed

+115
-2
lines changed

2 files changed

+115
-2
lines changed

packages/beidou-webpack/README-ZH.md

+58-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ exports.webpack = {
8181

8282
```js
8383
// webpack.config.js
84-
84+
// 配置方案1:
8585
module.exports = (app, defaultConfig, dev, target) => {
8686
return {
8787
...defaultConfig,
@@ -97,6 +97,63 @@ module.exports = (app, defaultConfig, dev, target) => {
9797
//something else to override
9898
};
9999
};
100+
101+
// 配置方案2:
102+
// 此方案将直接覆盖原有配置
103+
module.exports = {
104+
output: {
105+
path: './build',
106+
filename: '[name].js?[hash]',
107+
chunkFilename: '[name].js',
108+
publicPath: './build',
109+
},
110+
111+
resolve: {
112+
extensions: ['.json', '.js', '.jsx'],
113+
},
114+
115+
devServer: {
116+
contentBase: false,
117+
port: 6002,
118+
noInfo: true,
119+
quiet: false,
120+
clientLogLevel: 'warning',
121+
lazy: false,
122+
watchOptions: {
123+
aggregateTimeout: 300,
124+
},
125+
headers: { 'X-Custom-Header': 'yes' },
126+
stats: {
127+
colors: true,
128+
chunks: false,
129+
},
130+
publicPath: '/build',
131+
hot: true,
132+
},
133+
};
134+
135+
// 配置方案3:
136+
// 更多配置方法,可参看单测用例
137+
module.exports = (app, defaultConfig, dev, target) => {
138+
const factory = app.webpackFactory;
139+
factory.append({
140+
output: {
141+
path: outputPath,
142+
filename: '[name].js?[hash]',
143+
chunkFilename: '[name].modify.js',
144+
publicPath: '/build/',
145+
},
146+
})
147+
148+
const factoryInProd = factory.env('prod');
149+
factoryInProd.addPlugin(new webpack.optimize.UglifyJsPlugin({
150+
compress: {
151+
warnings: false,
152+
},
153+
}))
154+
155+
};
156+
100157
```
101158

102159
- **app**: `BeidouApplication` 示例, 通常用来读取应用的全局配置项。

packages/beidou-webpack/README.md

+57-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Config fields `output`, `resolve`, `devServer` are same as what you know in [web
8383

8484
```js
8585
// webpack.config.js
86-
86+
// Example 1:
8787
module.exports = (app, defaultConfig, dev, target) => {
8888
return {
8989
...defaultConfig,
@@ -99,6 +99,62 @@ module.exports = (app, defaultConfig, dev, target) => {
9999
//something else to override
100100
};
101101
};
102+
103+
// Exapple 2:
104+
// Note: The config will cover the default config
105+
module.exports = {
106+
output: {
107+
path: './build',
108+
filename: '[name].js?[hash]',
109+
chunkFilename: '[name].js',
110+
publicPath: './build',
111+
},
112+
113+
resolve: {
114+
extensions: ['.json', '.js', '.jsx'],
115+
},
116+
117+
devServer: {
118+
contentBase: false,
119+
port: 6002,
120+
noInfo: true,
121+
quiet: false,
122+
clientLogLevel: 'warning',
123+
lazy: false,
124+
watchOptions: {
125+
aggregateTimeout: 300,
126+
},
127+
headers: { 'X-Custom-Header': 'yes' },
128+
stats: {
129+
colors: true,
130+
chunks: false,
131+
},
132+
publicPath: '/build',
133+
hot: true,
134+
},
135+
};
136+
137+
// Example:
138+
// Please to find more methods in unittest
139+
module.exports = (app, defaultConfig, dev, target) => {
140+
const factory = app.webpackFactory;
141+
factory.append({
142+
output: {
143+
path: outputPath,
144+
filename: '[name].js?[hash]',
145+
chunkFilename: '[name].modify.js',
146+
publicPath: '/build/',
147+
},
148+
})
149+
150+
const factoryInProd = factory.env('prod');
151+
factoryInProd.addPlugin(new webpack.optimize.UglifyJsPlugin({
152+
compress: {
153+
warnings: false,
154+
},
155+
}))
156+
157+
};
102158
```
103159

104160
- **app**: the `BeidouApplication` instance, usually used to access server config.

0 commit comments

Comments
 (0)