-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a463f0
commit fcf1eff
Showing
2 changed files
with
27 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
import validateSchema from 'webpack/lib/validateSchema'; | ||
// import validateSchema from 'webpack/lib/validateSchema'; | ||
// import WebpackOptionsValidationError from 'webpack/lib/WebpackOptionsValidationError'; | ||
import packingOptionsSchema from '../schemas/packing-options'; | ||
import { pRequire } from '..'; | ||
// import packingOptionsSchema from '../schemas/packing-options'; | ||
// import { pRequire } from '..'; | ||
|
||
class PackingOptionsValidationError extends Error { | ||
constructor(message) { | ||
super(); | ||
this.name = 'PackingOptionsValidationError'; | ||
this.message = message; | ||
} | ||
} | ||
// class PackingOptionsValidationError extends Error { | ||
// constructor(message) { | ||
// super(); | ||
// this.name = 'PackingOptionsValidationError'; | ||
// this.message = message; | ||
// } | ||
// } | ||
|
||
/** | ||
* 校验 `config/packing.js` 参数 | ||
*/ | ||
export default () => { | ||
const options = pRequire('config/packing'); | ||
const packingOptionsValidationErrors = validateSchema(packingOptionsSchema, options); | ||
// const options = pRequire('config/packing'); | ||
// const packingOptionsValidationErrors = validateSchema(packingOptionsSchema, options); | ||
|
||
if (packingOptionsValidationErrors.length) { | ||
// 重写 error.message | ||
// 保证输出消息的可读性 | ||
// const error = new WebpackOptionsValidationError(packingOptionsValidationErrors); | ||
// const message = error.message.replace(/Webpack/mg, 'Packing'); | ||
throw new PackingOptionsValidationError(message); | ||
} | ||
// if (packingOptionsValidationErrors.length !== 0) { | ||
// // 重写 error.message | ||
// // 保证输出消息的可读性 | ||
// // const error = new WebpackOptionsValidationError(packingOptionsValidationErrors); | ||
// // const message = error.message.replace(/Webpack/mg, 'Packing'); | ||
// throw new PackingOptionsValidationError(packingOptionsValidationErrors); | ||
// } | ||
}; |