簡體   English   中英

如何為React App自定義Webpack構建腳本

[英]How to customize webpack build script for React App

因此,我正在移動一個Web應用程序以做出響應,然后將Grunt作為構建工具移到了webpack。 現在,下面的代碼是webpack.config文件。 這是為開發建議的設置,然后具有構建腳本(npm run和npm build)

但是,構建腳本現在僅連接組件/反應js文件,並將它們放在dist文件夾的根目錄下。 沒有其他文件被復制。 我僅能理解構建腳本的意義。 但是我需要能夠添加它,但是,沒有資源與reacts構建腳本一起顯示您將如何處理該問題

const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");

module.exports = {
  entry: "./app/src/components/app.js",
  output: {
    path: path.join(__dirname, "/dist"),
    filename: "index_bundle.js"
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader"
        }
      },
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader"]
      }
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: "./app/index.html"
    })
  ]
};

您不需要'/'

output: {
    path: path.join(__dirname, "dist"),
    filename: "index_bundle.js"
  },

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM