加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
webpack.config.ts 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
/** @format */
const _path = require("path")
const webpack = require("webpack")
const config = {
entry: "./src/index",
mode: "production",
resolve: {
modules: [_path.resolve(__dirname, "./src"), "node_modules"],
extensions: [".js", ".jsx", ".ts", ".tsx"],
},
module: {
rules: [
{
test: /\.s?css$/i,
use: ["style-loader", "css-loader", "sass-loader"],
},
{
test: /\.ts?$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env", "@babel/preset-typescript"],
plugins: [
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-transform-runtime"
],
},
},
},
{
test: /\.worker\.(c|m)?js$/i,
loader: "worker-loader",
options: { inline: "fallback" },
},
],
},
}
const configWeb = {
...config,
target: "web",
output: {
path: _path.resolve(__dirname, "lib"),
filename: "index.js",
libraryTarget: "umd",
},
}
const configNode = {
...config,
target: "node",
output: {
path: _path.resolve(__dirname, "lib"),
filename: "index.node.js",
libraryTarget: "umd",
},
}
module.exports = [configWeb, configNode]
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化