我正在使用:
"webpack": "^3.10.0",
"webpack-dev-server": "^2.9.7"
我的webpack.config.js:
var path = require("path");
module.exports = {
entry: "./src/index.js",
output: {
path: path.resolve(__dirname, "dist"),
publicPath: "/assets/",
filename: "bundle.js"
},
devServer: {
contentBase: path.join(__dirname, "dist"),
compress: true,
port: 9002
},
module: {
rules: [
{ test: /\.js$/, use: 'babel-loader' }
]
}
};
我的src / index.js包含
import ReactDOM from 'react-dom';
import React from 'react';
ReactDOM.render(
<h1>Curve!</h1>,
document.getElementById('root')
);
当我启动webpack-dev-server并转到localhost:9002时,我收到以下错误:
Content Security Policy:
The page’s settings blocked the loading of a resource at self (“default-src http://localhost:9002”).
Source: ;(function installGlobalHook(window) {
为什么会这样?