【发布时间】:2021-01-10 01:46:08
【问题描述】:
配置对象无效。 Webpack 已使用与 API 架构不匹配的配置对象进行初始化。
-
configuration.module 有一个未知属性“loaders”。这些属性是有效的: object { defaultRules?, exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, noParse?, rules?, strictExportPresence?, strictThisContextOnImports?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, WrappedContextCritical?, WrappedContextRecursive?, WrappedContextRegExp? } -> 影响正常模块的选项 (
NormalModuleFactory)。 -
configuration.output.path:提供的值“dist/assets”不是绝对路径! -> 输出目录为绝对路径(必需)。
在 React 教程课程中(“使用 webpack 构建”) (我用的是windows,但当然是在linux上)
var webpack = require("webpack");
module.exports = {
entry: "./src/index.js",
output: {
path: "dist/assets",
filename: "bundle.js",
publicPath: "assets"
},
devServer: {
inline: true,
contentBase: './dist',
port: 3000
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /(node_modules)/,
loader: ["babel-loader"],
query: {
presets: ["latest", "react", "stage-0"]
}
}
]
}
}
const { createElement } = React
const { render } = ReactDOM
const style = {
backgroundColor: 'orange',
color:'white',
fontFamily: 'verdana'
}
const title = createElement(
'h1',
{id:'title', className:'header', style: style},
'hello world'
)
render(
<h1 id='title'
className='header'
style={{backgroundColor:'orange'}}>
hello world
</h1>,
document.getElementById('react-container')
)
my cmd with command "webpack" to convert index.js to bundle.js
【问题讨论】:
-
这是一个编码站点,我们希望看到代码,而不仅仅是它输出的错误消息。请edit your question提供,(格式正确)。
-
@Compo 好的,谢谢 ;)
标签: reactjs webpack cmd webpack-dev-server