1 Star 0 Fork 2

shannonlin/ajax-hook

forked from healthy/ajax-hook 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
build.js 2.38 KB
一键复制 编辑 原始数据 按行查看 历史
chenyingyan.xy 提交于 2023-06-04 23:41 . fix: double hook error
/**
* Created by du on 16/9/24.
*/
let path = require('path');
let webpack = require('webpack');
let env = process.argv[2] || "dev"
console.log(env)
let entry = {
"ajaxhook": "./index.js",
}
let plugins = [];
var output={
path: path.resolve("./dist/")
}
if (env === "test") {
entry = {
"es": "./test/es.js",
'hook': './test/hook.js',
'proxy': './test/proxy.js'
}
output = {
path: path.resolve("./test/dist"),
filename: "[name].js"
}
} else if (env === "cdn") {
entry = {
"ajaxhook": "./src/cdn.js",
"ajaxhook.core": "./src/cdn-core.js",
}
output.filename = "[name].js"
output.libraryTarget = 'window'
} else if (env === "cdn-min") {
entry = {
"ajaxhook": "./src/cdn.js",
"ajaxhook.core": "./src/cdn-core.js",
// "ajaxhook": "./src/xhr-proxy.js",
// "ajaxhook.core": "./src/xhr-hook.js",
}
output.filename = "[name].min.js"
output.libraryTarget = 'window'
plugins.push(new webpack.optimize.UglifyJsPlugin({
// compress: {
// warnings: true
// },
sourceMap: true
}))
}
else if (env === "umd") {
output.libraryTarget = "umd"
output.filename = "[name].umd.js"
}else if (env === "umd-min") {
output.libraryTarget = "umd"
output.filename = "[name].umd.min.js"
plugins.push(new webpack.optimize.UglifyJsPlugin({
// compress: {
// warnings: true
// },
sourceMap: true
}))
}
let config = {
devtool: env.endsWith('min')?'source-map':'none',
entry: entry,
output: output,
module: {
rules: [
{
test: /\.js$/,
include: [path.resolve('./src'), path.resolve('./test'), path.resolve('./index.js')],
use: [
{
loader: "babel-loader",
options: {
presets: ['es2015']
}
},
]
}
]
},
watch: true,
watchOptions: {
ignored: '**/node_modules',
},
plugins: plugins
}
webpack(config, function (err, stats) {
if (err) throw err;
process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false
}) + '\n')
});
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/shannonlin/ajax-hook.git
git@gitee.com:shannonlin/ajax-hook.git
shannonlin
ajax-hook
ajax-hook
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385