Have 2 bundles
This commit is contained in:
parent
258c1e6ff0
commit
c38b7c9972
3 changed files with 78 additions and 57 deletions
|
|
@ -1,37 +1,55 @@
|
|||
const path = require("path");
|
||||
const path = require('path');
|
||||
const { merge } = require('webpack-merge');
|
||||
|
||||
|
||||
module.exports = {
|
||||
entry: "./src/index.ts",
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.ts$/,
|
||||
use: ["ts-loader"]
|
||||
},
|
||||
{
|
||||
test: /\.wasm$/,
|
||||
type: "asset/inline"
|
||||
}
|
||||
]
|
||||
},
|
||||
optimization: {
|
||||
// the consuming project should take care of minification
|
||||
minimize: false
|
||||
},
|
||||
resolve: {
|
||||
extensions: [".ts"],
|
||||
alias: {
|
||||
root: __dirname,
|
||||
src: path.resolve(__dirname, "src")
|
||||
}
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, "dist"),
|
||||
filename: "index.js",
|
||||
libraryTarget: "module"
|
||||
},
|
||||
experiments: {
|
||||
outputModule: true
|
||||
const common = {
|
||||
entry: './src/index.ts',
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.ts$/,
|
||||
use: ['ts-loader'],
|
||||
},
|
||||
{
|
||||
test: /\.wasm$/,
|
||||
type: 'asset/inline',
|
||||
},
|
||||
],
|
||||
},
|
||||
optimization: {
|
||||
// the consuming project should take care of minification
|
||||
minimize: false,
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.ts', '.js'],
|
||||
alias: {
|
||||
root: __dirname,
|
||||
src: path.resolve(__dirname, 'src'),
|
||||
},
|
||||
},
|
||||
performance: {
|
||||
hints: false, // it's a library, no need to warn about its size
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = [
|
||||
merge(common, {
|
||||
target: 'web',
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
filename: 'reconcile.web.js',
|
||||
library: {
|
||||
name: 'reconcile',
|
||||
type: 'umd',
|
||||
},
|
||||
globalObject: 'this',
|
||||
},
|
||||
}),
|
||||
merge(common, {
|
||||
target: 'node',
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
filename: 'reconcile.node.js',
|
||||
libraryTarget: 'commonjs2',
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue