mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
优化结构
This commit is contained in:
1 parent
75ebc1a746
commit
2554cf660a
34 files changed
+401
-150
No files matched your search
+11
-9
@@ -1,11 +1,13 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
const fs = require('fs');
|
||||
const webpack = require('webpack');
|
||||
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
|
||||
const root = require('./root');
|
||||
const build = async () => {
|
||||
|
||||
const build = async (type) => {
|
||||
function hackNodeModuleFormidable() {
|
||||
const tasks = ['incoming_form', 'file', 'json_parser', 'querystring_parser'];
|
||||
for (let task of tasks) {
|
||||
for (const task of tasks) {
|
||||
let file = fs.readFileSync(root(`node_modules/formidable/lib/${task}.js`)).toString();
|
||||
if (file.startsWith('if (global.GENTLY) require = GENTLY.hijack(require);')) {
|
||||
file = file.split('\n');
|
||||
@@ -18,22 +20,22 @@ const build = async () => {
|
||||
hackNodeModuleFormidable();
|
||||
|
||||
const config = {
|
||||
mode: 'development',
|
||||
mode: type,
|
||||
entry: {
|
||||
development: root('hydro/development.js'),
|
||||
install: root('hydro/install.js'),
|
||||
uninstall: root('hydro/uninstall.js')
|
||||
uninstall: root('hydro/uninstall.js'),
|
||||
},
|
||||
output: {
|
||||
filename: '[name].js',
|
||||
path: root('.build')
|
||||
path: root('.build'),
|
||||
},
|
||||
target: 'node',
|
||||
module: {},
|
||||
plugins: [
|
||||
new webpack.ProgressPlugin(),
|
||||
new FriendlyErrorsPlugin(),
|
||||
]
|
||||
],
|
||||
};
|
||||
const compiler = webpack(config);
|
||||
await new Promise((resolve, reject) => {
|
||||
@@ -41,12 +43,12 @@ const build = async () => {
|
||||
if (err) {
|
||||
console.error(err.stack || err);
|
||||
if (err.details) console.error(err.details);
|
||||
reject(1);
|
||||
reject();
|
||||
}
|
||||
if (stats.hasErrors()) process.exitCode = 1;
|
||||
resolve();
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = build;
|
||||
Reference in new issue
Block a user