javascript - webpack not producing output files - Stack Overflow

I am currently trying to run webpack with the mand set NODE_ENV=production && webpack (Window U

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')

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745635649a4637375.html

相关推荐

  • javascript - webpack not producing output files - Stack Overflow

    I am currently trying to run webpack with the mand set NODE_ENV=production && webpack (Window U

    3小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信