这是我的webpack配置 ,图片打包进去了,可是在另一个项目中link时却加载不到
const path = require(“path”);
const CleanWebpackPlugin = require(“clean-webpack-plugin”);
const BundleAnalyzerPlugin = require(“webpack-bundle-analyzer”)
.BundleAnalyzerPlugin;
module.exports = { mode: "production",
resolve: { extensions: [".mjs", ".web.js", ".js", ".json", ".web.jsx", ".jsx"] },
entry: { index: "./src/index.js" },
output: { filename: "[name].js", path: path.resolve(__dirname, "dist"), libraryTarget: "commonjs2" }, // optimization: { // splitChunks: { // chunks: "all" // } // }, module: { rules: [ { test: /\.(js|jsx)$/, exclude: /node_modules/, loader: "babel-loader" }, { test: /\.css$/, use: ["style-loader", "css-loader", "postcss-loader"] }, { test: /\.(png|jpg|jpeg|gif|svg)$/, use: [ { loader: "file-loader", options: { outputPath: "/static/", publicPath: './', limit: 10240 // size <= 20KB, } } ] }, { test: /\.(woff|woff2|eot|ttf|otf)$/, use: [ { loader: "file-loader", options: { outputPath: "/static/" // publicPath: "dist/", } } ] } ] },
plugins: [new CleanWebpackPlugin(["dist"]), new BundleAnalyzerPlugin()] };