简体   繁体   English

Webpack错误:未配置输出文件名

[英]Webpack error : output filename not configured

// webpack.config.js
const webpack = require('webpack');
const path = require('path');

module.exports = {
  entry: path.join(__dirname, 'src', 'app-client.js'),
  output: {
    path: path.join(__dirname, 'src', 'static', 'js'),
    filename: 'bundle.js'
  },
  module: {
    loaders: [{
      test: path.join(__dirname, 'src'),
      loader: ['babel-loader'],
      query: {
        cacheDirectory: 'babel_cache',
        presets: ['react', 'es2015']
      }
    }]
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
    }),
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.UglifyJsPlugin({
      compress: { warnings: false },
      mangle: true,
      sourcemap: false,
      beautify: false,
      dead_code: true
    })
  ]
};

I have checked the filename is webpack.config.js . 我检查了文件名是webpack.config.js

File is in root directory of project. 文件位于项目的根目录中。

It has module.exports . 它具有module.exports

So what could possibly go wrong ? 那么怎么可能出问题了?

Error is showing output filename not configured when running 错误显示运行时output filename not configured

NODE_ENV=production node_modules/.bin/webpack -p

current directory is root project /myproject$ 当前目录是根项目/myproject$

UPDATE 更新

Its solved 解决了

In case anyone comes around . 万一有人过来。 this error happened because i had no /js/ folder inside /src/ . 发生此错误是因为我在/src/没有/js/文件夹。 Looks like webpack dosent creates folders. 看起来像webpack目录创建了文件夹。 So after i created the folder using mkdir it worked smooth. 因此,在我使用mkdir创建文件夹后,它可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM