Webpack = Move my index.html, add it to a folder

0

I am a frontend developer, and I am implementing webpack to improve a bit a web app that I am doing in react js.

But I have a problem = > When I configure my webpack in the parameter publicPath: path.resolve(__dirname, "dist") + "/" it does not allow me to change my html index from the root of the project to a public folder where it should be.

If I do this by changing the address, the application does not break but the webpack interface leaves with each of the folders and until it does not enter the folder where the index html is, the application is executed and then the nose executes and precedes the url localhost:3001/public/#/ . I do not understand how I can solve this.

Currently how is my application.

- webpack.config.js -

const path = require("path");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");

module.exports = env => {
  const plugins = [new ExtractTextPlugin("css/[name].[hash].css")];

  if (env.NODE_ENV === "production") {
    plugins.push(new CleanWebpackPlugin(["dist"], { root: __dirname }));
  }
  return {
    entry: {
      "newfrontsdea": path.resolve(__dirname, "./src/index.js")
    },
    output: {
      path: path.resolve(__dirname, "dist"),
      filename: "js/[name].js",
      publicPath: path.resolve(__dirname, "dist") + "/",
      chunkFilename: "js/[id].[chunkhash].js"
    },
    devServer: {
      port: 3001
    },
    module: {
      rules: [
        {
          // test: que tipo de archivo quiero reconocer,
          // use: que loader se va a encargar del archivo
          test: /\.(js|jsx)$/,
          exclude: /(node_modules)/,
          use: {
            loader: "babel-loader",
            options: {
              presets: ["es2015", "react", "stage-2"]
            }
          }
        },
        {
          test: /\.css$/,
          use: ExtractTextPlugin.extract({
            use: [
              {
                loader: "css-loader",
                options: {
                  minimize: true
                }
              }
            ]
          })
        },
        {
          test: /\.(jpg|png|gif|svg)$/,
          use: {
            loader: "url-loader",
            options: {
              limit: 10000,
              fallback: "file-loader",
              name: "images/[name].[hash].[ext]"
            }
          }
        }
      ]
    },
    plugins
  };
};

- Current structure of my project

How can I change the direction of the index.html of my project to a public folder ?

    
asked by jcfb90 28.09.2018 в 16:16
source

0 answers