1 Star 0 Fork 8

ForeverAct/Background-RemovalJS

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
webpack.config.js 1.99 KB
一键复制 编辑 原始数据 按行查看 历史
const path = require('path');
const pkg = require('./package.json');
module.exports = (env, argv) => {
const isDevelopment = argv.mode === 'development';
const publicPath = isDevelopment
? undefined
: `https://unpkg.com/${pkg.name}@${pkg.version}/dist/`;
const commonConfig = {
devtool: 'source-map',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpeg|jpg)$/i,
type: 'asset/resource',
generator: {
publicPath: publicPath
}
},
{
test: /\.(onnx)$/i,
type: 'asset/resource',
generator: {
publicPath: publicPath
}
},
{
test: /\.(wasm)$/i,
type: 'asset/resource',
generator: {
publicPath: publicPath
}
}
]
},
resolve: {
extensions: ['.ts', '.js']
},
optimization: {
splitChunks: {
chunks: 'async'
}
}
};
const umdConfig = {
...commonConfig,
entry: './src/browser.ts',
target: 'web',
output: {
filename: 'browser.js',
path: path.resolve(__dirname, 'dist'),
publicPath: publicPath,
library: {
type: 'umd',
name: 'backgroundRemoval'
}
}
};
const esmConfig = {
...commonConfig,
experiments: {
outputModule: true // needed for esm
},
entry: './src/browser.ts',
target: 'web',
output: {
filename: 'browser.mjs',
path: path.resolve(__dirname, 'dist'),
publicPath: publicPath,
library: {
type: 'module'
}
}
};
const nodeConfig = {
...commonConfig,
entry: './src/node.ts',
target: 'node',
output: {
filename: 'node.js',
path: path.resolve(__dirname, 'dist'),
library: {
type: 'umd',
name: 'backgroundRemoval'
}
}
};
return [umdConfig, esmConfig];
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/ForeverAct/Background-RemovalJS.git
git@gitee.com:ForeverAct/Background-RemovalJS.git
ForeverAct
Background-RemovalJS
Background-RemovalJS
main

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385