我正在尝试设置反应路由,当我点击我的网站上的某些东西时路由有效,但是如果我打开一个新的选项卡并复制该URL.我明白了
Refused to execute script from 'http://localhost:8080/something/index_bundle.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
Run Code Online (Sandbox Code Playgroud)
webpack.config
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
entry: "./src/index.js",
output: {
path: path.join(__dirname, "/dist"),
filename: "index_bundle.js"
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
},
{
test: /\.s?css$/,
use: [
{
loader: "style-loader" // creates style nodes from JS strings
},
{
loader: "css-loader" // translates …Run Code Online (Sandbox Code Playgroud) 我正在用 webpack4 测试 react-router4,但我无法获得 webpack-dev-server 的设置:
{historyApiFallback: true}
Run Code Online (Sandbox Code Playgroud)
上班。这个用法在 webpack3 中工作得很好,所以我不确定是什么问题......这是我的 webpack.config.js:
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = () => {
return {
mode: 'development',
devtool: 'source-map',
devServer: {
port: 8888,
historyApiFallback: true,
stats: 'minimal'
},
resolve: {
extensions: ['*', '.mjs', '.js', '.jsx']
},
module: {
rules: [
{
test: /\.m?jsx?$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader'
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
title:'React Lab',
template: 'src/index.html'
})
]
}
}
Run Code Online (Sandbox Code Playgroud)
这是我使用 react-router4 的简单反应应用程序:
import React from 'react'; …Run Code Online (Sandbox Code Playgroud)