简体   繁体   English

当我运行npm start时,未创建我的主输出文件

[英]When I run npm start, my main output file isn't created

I'm building a react app with webpack and when I run npm start, I get a success message with no errors but I don't see the main output file that it's supposed to create isn't made. 我正在使用webpack构建一个React应用,当我运行npm start时,我收到一条成功消息,没有错误,但是我没有看到应该创建的主要输出文件。

I'm using webpack and here is my webpack.config.js file 我正在使用webpack,这是我的webpack.config.js文件

module.exports = {
  entry: './src/app.jsx',
  output: {
    path: __dirname,
    publicPath: '/',
    filename: 'main.js'
  },
  module: {
    loaders: [{
      exclude: /node_modules/,
      loader: 'babel'
    }]
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  devServer: {
    historyApiFallback: true,
    contentBase: './'
  }
};

Not sure what else is necessary to provide for help with this issue but I'd be happy to provide it. 不知道要为该问题提供帮助还需要什么,但我很乐意提供。 All of my jsx code is inside an src/ folder in the root directory. 我所有的jsx代码都位于根目录下的src /文件夹中。

What you are launching with npm start is the webpack-dev-server (as you specified in the comments). 使用npm start是webpack-dev-server(如注释中所指定)。 This won't create any file on your hard drive. 这不会在您的硬盘上创建任何文件。 By default, it will open a server on http://localhost:8080/ serving your bundle (everything staying in memory). 默认情况下,它将在http:// localhost:8080 /上打开一个服务器,为您的捆绑软件提供服务(一切都留在内存中)。

If you want to build your bundle (make the main.js file on your hardrive), so that you could distribute it on production, you need to run ./node_modules/.bin/webpack --progress . 如果要构建捆绑包(在hardrive上制作main.js文件),以便可以在生产环境中分发它,则需要运行./node_modules/.bin/webpack --progress

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

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