没有生成错误,捆绑文件输出不会重新生成

时间:2018-03-09 10:54:31

标签: reactjs webpack babel package.json webpack.config.js

webpack的新手试图了解如何使文件结构webpack.config.jspackage.json一起工作,但不知道什么是失败的client.min.js(我输出的bunfdle)文件)永远不会在NPM run dev

上重新生成

webpack.config.js:

var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');

module.exports = {
  context: path.join(__dirname, "src"),
  devtool: debug ? "inline-sourcemap" : null,
  entry: "./js/client.js",
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /(node_modules|bower_components)/,
        loader: 'babel-loader',
        query: {
          presets: ['react', 'es2015', 'stage-0'],
          plugins: ['react-html-attrs', 'transform-class-properties', 'transform-decorators-legacy'],
        }
      }
    ]
  },
  output: {
    path: __dirname+"/src/",
    filename: "client.min.js"
  },
  plugins: debug ? [] : [
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
  ],
};

的package.json:

 {
  "name": "appThing",
  "version": "0.0.0",
  "main": "webpack.config.js",
  "dependencies": {
    "babel-core": "^6.18.2",
    "babel-loader": "^6.2.0",
    "babel-plugin-add-module-exports": "^0.1.2",
    "babel-plugin-react-html-attrs": "^2.0.0",
    "babel-plugin-transform-class-properties": "^6.3.13",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-preset-es2015": "^6.3.13",
    "babel-preset-react": "^6.3.13",
    "babel-preset-stage-0": "^6.3.13",
    "flux": "^2.1.1",
    "history": "^1.17.0",
    "react": "^0.14.6",
    "react-dom": "^0.14.6",
    "react-router": "^1.0.3",
    "webpack": "^2",
    "webpack-dev-server": "^2"
  },
  "scripts": {
    "dev": "webpack-dev-server --content-base src --inline --hot"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "webpack": "^2.7.0",
    "webpack-cli": "^2.0.10"
  },
  "description": ""
}

文件结构:

enter image description here NPM运行开发结果:

enter image description here

1 个答案:

答案 0 :(得分:1)

Printer不会生成文件。它从内存中提供所有资产。

如果要生成文件,请运行MyPrinter