Webpack - 没有错误,但webpack.config.js没有输出bundle.js文件

时间:2018-01-26 20:01:58

标签: javascript node.js reactjs webpack babel

我正在关注一个简​​单的反应应用教程,并遇到了使用Babel和Webpack创建bundle.js文件的问题。我的终端未显示任何错误,但未创建bundle.js文件并将其发送至/src/static/js/

以下是webpack.config.js文件:

"use strict";

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.UglifyJsPlugin({
      compress: { warnings: false },
      mangle: true,
      sourcemap: false,
      beautify: false,
      dead_code: true
    })
  ]
};

这些是我目前安装的依赖项,以防有一个我缺少的包:

    "dependencies": {
    "babel": "^6.23.0",
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "ejs": "^2.5.7",
    "express": "^4.16.2",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-router": "^4.2.0"
  },
  "devDependencies": {
    "babel-loader": "^7.1.2",
    "http-server": "^0.11.1",
    "webpack": "^3.10.0"
  }

本教程让您在终端中运行以下命令:

NODE_ENV=production node_modules/.bin/webpack -p

这个命令没有解释,所以我不太清楚它在做什么。

0 个答案:

没有答案