刷新为响应路由器在Webpack生产构建上给出404错误

时间:2020-08-06 09:14:40

标签: reactjs webpack react-router

这是公共目录中htaccess的代码

        public List<OutLookEmails> ReadMailItems()
        {
            Application OutlookApplication = null;
            NameSpace OutlooknameSpace = null;
            MAPIFolder InboxFolder = null;

            Items mailItems = null;
            List<OutLookEmails> ListEmailDetails = new List<OutLookEmails>();
            OutLookEmails EmailDetails;

            try
            {
                OutlookApplication = new Application();
                OutlooknameSpace = OutlookApplication.GetNamespace("MAPI");
                InboxFolder = OutlooknameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
                mailItems = InboxFolder.Items;
                foreach (MailItem item in mailItems)
                {
                    EmailDetails = new OutLookEmails();
                    EmailDetails.EmailFrom = item.SenderEmailAddress;
                    EmailDetails.EmailSubject = item.Subject;
                    EmailDetails.EmailBody = item.Body;
                    ListEmailDetails.Add(EmailDetails);
                    ReleaseComObject(item);
                }
            }
            catch (s.Exception Ex)
            {


            }
            finally
            {
                ReleaseComObject(mailItems);
                ReleaseComObject(InboxFolder);
                ReleaseComObject(OutlooknameSpace);
                ReleaseComObject(OutlookApplication);

            }
            return ListEmailDetails;
        }
    }
   private static void ReleaseComObject(Object obj)
    {
        if (obj != null)
        {
            System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
            obj = null;
        }
    }

  public IActionResult GetMail()
    {
        OutLookEmails em = new OutLookEmails();
        var Mails = em.ReadMailItems();
        foreach (var Mail in Mails)
        { 
        
        }
       // return View();
    }

我试图将其重写为

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]

这是我的webconfig文件

RewriteBase /
RewriteCond %{REQUEST_URI} !^/(assets/?|$)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]

这是我的基本重定向

/**
 * Main file of webpack config.
 * Please do not modified unless you know what to do
 */
import webpack from 'webpack';
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const WebpackRTLPlugin = require("webpack-rtl-plugin");
const WebpackMessages = require("webpack-messages");
const del = require("del");
const ASSET_PATH = process.env.ASSET_PATH || '/';

// theme name
const themeName = "metronic";
// global variables
const rootPath = path.resolve(__dirname);
const distPath = rootPath + "/build";

const entries = {
    "sass/style.react": "./src/index.scss"
};

const mainConfig = function () {
    return {
        devServer: {
            historyApiFallback: true,
        },
        mode: "development",
        stats: "errors-only",
        performance: {
            hints: false
        },
        entry: entries,
        output: {
            // main output path in assets folder
            path: distPath,
            // output path based on the entries' filename
            filename: "[name].js",
            publicPath: ASSET_PATH,
        },
        resolve: {extensions: ['.scss']},
        plugins: [
            // webpack log message
            new WebpackMessages({
                name: themeName,
                logger: str => console.log(`>> ${str}`)
            }),
            new webpack.DefinePlugin({
                'process.env.ASSET_PATH': JSON.stringify(ASSET_PATH),
              }),
            // create css file
            new MiniCssExtractPlugin({
                filename: "[name].css",
            }),
            new WebpackRTLPlugin({
                filename: "[name].rtl.css",
            }),
            {
                apply: (compiler) => {
                    // hook name
                    compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => {
                        (async () => {
                            await del.sync(distPath + "/sass/*.js", {force: true});
                        })();
                    });
                }
            },
        ],
        module: {
            rules: [
                {
                    test: /\.scss$/,
                    use: [
                        MiniCssExtractPlugin.loader,
                        "css-loader",
                        {
                            loader: "sass-loader",
                            options: {
                                sourceMap: true,
                            }
                        },
                    ]
                },
            ]
        },
    }
};

module.exports = function () {
    return [mainConfig()];
};

0 个答案:

没有答案