我正在尝试测试 Webpack 的摇树功能,但它似乎不起作用。
这是我的文件:
index.tsimport { good } from './exports';
console.log(good);
Run Code Online (Sandbox Code Playgroud)
exports.tsexport const good = 'good';
export const secret = 'iamasecret';
Run Code Online (Sandbox Code Playgroud)
tsconfig.json{}
Run Code Online (Sandbox Code Playgroud)
webpack.config.tsimport { Configuration } from 'webpack';
import * as TerserPlugin from "terser-webpack-plugin";
const config: Configuration = {
mode: 'production',
entry: './index.ts',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [ '.tsx', '.ts', '.js' ]
},
optimization: {
usedExports: true,
minimizer: [new TerserPlugin()],
}
}
export …Run Code Online (Sandbox Code Playgroud)