简体   繁体   English

Webpack构建步骤未生成构建文件

[英]Webpack build step isn't generating build files

When I run npm build nothing seems to happen. 当我运行npm build似乎什么都没有发生。 When I look for the build files I don't see anything. 当我寻找构建文件时,我什么也看不到。 npm start works fine though. npm start可以正常工作。

Package.json Package.json

{
  "name": "pro-react-webpack",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "webpack-dev-server --progress",
    "build": "NODE_ENV=production webpack --config ./webpack.production.config.js --progress",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.10.4",
    "babel-loader": "^6.2.4",
    "babel-plugin-react-transform": "^2.0.2",
    "babel-preset-es2015": "^6.9.0",
    "babel-preset-react": "^6.11.1",
    "css-loader": "^0.23.1",
    "extract-text-webpack-plugin": "^1.0.1",
    "html-webpack-plugin": "^2.22.0",
    "json-loader": "^0.5.4",
    "postcss-loader": "^0.9.1",
    "precss": "^1.4.0",
    "react-transform-hmr": "^1.0.4",
    "style-loader": "^0.13.1",
    "webpack": "^1.13.1",
    "webpack-dev-server": "^1.14.1"
  },
  "dependencies": {
    "react": "^15.2.1",
    "react-dom": "^15.2.1"
  }
}

Webpack.production.config.js Webpack.production.config.js

var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
    entry: __dirname + "/app/main.js",
    output: {
        path: __dirname + "/build",
        filename: "bundle.js"
    },

    module: {
        loaders: [
            {
                test: /\.json$/,
                loader: "json"
            },
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: 'babel'
            },
            {
                test: /\.css$/,
                loader: ExtractTextPlugin.extract('style', 'css?modules!postcss')
            }
        ]
    },
    postcss: [
        require('autoprefixer')
    ],

    plugins: [
        new HtmlWebpackPlugin({
            template: __dirname + "/app/index.tmpl.html"
        }),
        new webpack.optimize.OccurenceOrderPlugin(),
        new webpack.optimize.UglifyJsPlugin(),
        new ExtractTextPlugin("style.css")
    ]
}

I also have .babelrc file and webpack.config.js file, let me know if those would be useful to see as well, thanks. 我也有.babelrc文件和webpack.config.js文件,请让我知道它们是否也很有用,谢谢。

Might be related to the fact that build is an internal command. 可能与build是一个内部命令有关。 Seems like I have had this happen to me as well in the past. 好像我过去也发生过这种情况。 Check out this Question 看看这个问题

In order to run a custom script, you can use the npm run-script build or just npm run build . 为了运行自定义脚本,您可以使用npm run-script build或仅使用npm run build As stated in the NPM documentation NPM文档中所述

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

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