昨天我用我当前的设置运行Webpack很好但是当我今天回到我的项目工作时出现这个错误:
/Users/user1/Documents/AAA/webpack.config.js:13
output.path: "[name].js",
^
SyntaxError: Unexpected token .
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at requireConfig (/Users/user1/Documents/AAA/node_modules/webpack/bin/convert-argv.js:96:18)
这是我的webpack.config.js文件:
const path = require('path');
module.exports = {
context: __dirname + "/app",
entry: {
app: "./src/app.js",
javascript: "./js/app.js",
html: "./index.html",
},
output: {
output.path: "[name].js",
path: __dirname + "/dist",
//chunkFilename: '[id].[chunkhash].js',
},
resolve: {
alias: { 'react/lib/ReactMount': 'react-dom/lib/ReactMount' },
extensions: [ '*', '.js', '.jsx', '.json'],
modules:[__dirname, './app/js', 'node_modules'],
},
module: {
rules: [
{
test: /\.jsx?$/,
include: [
path.resolve(__dirname, "app")
],
loaders: ["babel-loader"],
},
{
test: /\.html$/,
loader: ["file-loader?name=[name].[ext]"],
}
],
},
}
我只添加了app: "./src/app.js",
,因为我遇到了webpack dev服务器的问题。当我重新启动webpack --watch时,我开始收到此错误。我该如何解决这个问题?
答案 0 :(得分:3)
output
不是valid。
此
output: {
output.path: "[name].js",
path: __dirname + "/dist",
//chunkFilename: '[id].[chunkhash].js',
},
应该是
output: {
path: __dirname + "/dist",
filename: "[name].js"
}