最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - webpack not producing output files - Stack Overflow

matteradmin6PV0评论

I am currently trying to run webpack with the mand set NODE_ENV=production && webpack (Window User) But there was no output within the src directory with the name bundle.js, in fact there was no output file.

I have only used webpack-dev-server until now, so this is the first time I try to build a config file with plugins. webpack-dev-server as I have tried, is running okay.

src folder contains all my files including html and javascript.

I need an output files with working minified and pressed codes. Please assist and advise!!

The below was found in the terminal

Hash: 09ea2200290287327c75
Version: webpack 1.13.2
Time: 6976ms
    Asset     Size  Chunks             Chunk Names
bundle.js  3.48 MB       0  [emitted]  main
   [0] multi main 28 bytes {0} [built]
   [1] ./src/index.js 2.73 kB {0} [built]
    + 12 hidden modules

I do have a webpack.config.js file that has the below config.

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

module.exports = {
  entry: [
    './src/index.js'
  ],
  output: {
    path: path.resolve(__dirname,'/src'),
    filename: 'bundle.js'
  },
  devtool: debug ? "inline-sourcemap" : null,
  module: {
    loader: [{
      exclude: /node_modules/,
      loader: 'babel',
      query: {
        presets: ['angular']
      }
    }]
  },
  devServer: {
    historyApiFallback: true,
    contentBase: 'src'
  },
  plugins: debug ? [] : [
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.UglifyJsPlugin({
      press: { warnings: false }
    })
  ]
};

I am currently trying to run webpack with the mand set NODE_ENV=production && webpack (Window User) But there was no output within the src directory with the name bundle.js, in fact there was no output file.

I have only used webpack-dev-server until now, so this is the first time I try to build a config file with plugins. webpack-dev-server as I have tried, is running okay.

src folder contains all my files including html and javascript.

I need an output files with working minified and pressed codes. Please assist and advise!!

The below was found in the terminal

Hash: 09ea2200290287327c75
Version: webpack 1.13.2
Time: 6976ms
    Asset     Size  Chunks             Chunk Names
bundle.js  3.48 MB       0  [emitted]  main
   [0] multi main 28 bytes {0} [built]
   [1] ./src/index.js 2.73 kB {0} [built]
    + 12 hidden modules

I do have a webpack.config.js file that has the below config.

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

module.exports = {
  entry: [
    './src/index.js'
  ],
  output: {
    path: path.resolve(__dirname,'/src'),
    filename: 'bundle.js'
  },
  devtool: debug ? "inline-sourcemap" : null,
  module: {
    loader: [{
      exclude: /node_modules/,
      loader: 'babel',
      query: {
        presets: ['angular']
      }
    }]
  },
  devServer: {
    historyApiFallback: true,
    contentBase: 'src'
  },
  plugins: debug ? [] : [
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.UglifyJsPlugin({
      press: { warnings: false }
    })
  ]
};
Share Improve this question asked Sep 21, 2016 at 11:38 Winson LiaoWinson Liao 1032 silver badges8 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

This doesn't do what you are expecting:

path : path.resolve(__dirname, '/src')

Because it resolves to /src, and not—as you probably expected—"src/ in the current directory".

For that, use this:

path : path.resolve(__dirname, 'src')
Post a comment

comment list (0)

  1. No comments so far