插件: [ 新的网络包.LoaderOptionsPlugin({ // test: /\.xxx$/, // 可能只


var webpack = require("webpack");
var path = require("path");
var DIST_DIR = path.resolve(__dirname, "dist");
var SRC_DIR = path.resolve(__dirname, "src");
var config = {
entry: SRC_DIR + "/app/index.js",
output: {
path: DIST_DIR + "/app",
filename: "bundle.js",
publicPath: "/app/"
},
modules: {
loaders: [
{
test: /.js?/,
include: SRC_DIR,
loader: "babel-loader",
query: {
presets: [["react","es2015","stage-2"]]
} 
}

]
}
};
module.exports = config;

{
"name": "react-app",
"version": "1.0.0",
"description": "my first react app",
"main": "index.js",
"scripts": {
"start": "npm run build",
"build": "webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --hot",
"build:prod": "webpack -p && cp src/index.html dist/index.html"
},
"keywords": [
""React""
],
"author": "Dnyanesh",
"license": "ISC",
"dependencies": {
"@babel/core": "^7.0.0-beta.40",
"@babel/preset-env": "^7.0.0-beta.40",
"react": "^16.2.0",
"react-dom": "^16.2.0"
},
"devDependencies": {
"babel-loader": "^8.0.0-beta.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"webpack": "^4.1.0",
"webpack-cli": "^2.0.10",
"webpack-dev-server": "^3.1.0"
}
}

配置对象无效。Webpack 已使用与 API 架构不匹配的配置对象进行初始化。 - 配置具有未知属性"模块"。这些属性有效: 对象 { mode?, amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, externals?, loader?, module?, name?, node?, output?, optimization?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? } 对于错别字:请更正。 对于加载器选项:webpack>= v2.0.0 不再允许配置中的自定义属性。 加载器应更新为允许通过 module.rules 中的加载器选项传递选项。 在加载器更新之前,可以使用 LoaderOptionsPlugin 将这些选项传递给加载器: 插件:[ 新的网络包。LoaderOptionsPlugin({ test:/.xxx$/,//可能仅适用于某些模块 选项:{ 模块:。。。 } }) ]

由于错误清楚地表明您的配置应包含module而不是modules在此处检查

const webpack = require('webpack');
const path = require('path');
const DIST_DIR = path.resolve(__dirname,"dist");
const SRC_DIR = path.resolve(__dirname,"src");
module.exports = {
entry: SRC_DIR + "/app/index.js",
output: {
path: DIST_DIR + "/app",
filename: "bundle.js",
publicPath: "/app/"
},
module: {
rules: [
{
test: /.js?$/,
include: SRC_DIR,
loaders: "babel-loader",
options: {
presets: ["react", "es2016", "stage-2"]
}
}

]
},
performance: {
hints: process.env.NODE_ENV === 'production' ? "warning" : false
}
};

相关内容

最新更新