webpack不输出包文件

时间:2017-06-12 14:14:22

标签: webpack

这是我的文件夹结构:

config
 |--webpack.config.js
entry
 |--app.js
output

这是我的webpack.config.js文件内容的一部分:

module.exports = {
    context: path.join(__dirname, '..'),
    entry: {
        app: './entry/app.js'
    },
    output: {
        path: path.resolve('.', 'output'),
        filename: '[name].bundle.js'
    },

当我运行webpack时,output文件夹中没有文件输出。但是,终端没有显示任何错误,app.bundle.js似乎已经被隔离了。

Hash: 0d0e4e77f57e49724b60
Version: webpack 2.6.1
Time: 22416ms
        Asset    Size  Chunks                    Chunk Names
app.bundle.js  389 kB       0  [emitted]  [big]  app
chunk    {0} app.bundle.js (app) 1.1 MB [entry] [rendered]
   [26] ./~/react/lib/React.js 3.34 kB {0} [built]
  [100] ./~/react/react.js 55 bytes {0} [built]
  [116] ./entry/app.js 465 bytes {0} [built]
  [117] (webpack)-dev-server/client?http://localhost:8080 5.64 kB {0} [built]
  [124] ./~/events/events.js 8.45 kB {0} [built]
  [151] ./~/react-dom/index.js 58 bytes {0} [built]
  [262] ./~/strip-ansi/index.js 161 bytes {0} [built]
  [265] ./~/url/url.js 23.1 kB {0} [built]
  [267] (webpack)-dev-server/client/overlay.js 3.61 kB {0} [built]
  [268] (webpack)-dev-server/client/socket.js 872 bytes {0} [built]
  [269] (webpack)/hot/emitter.js 89 bytes {0} [built]
  [270] ./src/scripts/module_b_es6.js 128 bytes {0} [built]
  [271] ./src/scripts/react_components/head.jsx 2.32 kB {0} [built]
  [274] ./src/styles/style.css 911 bytes {0} [built]
  [275] multi (webpack)-dev-server/client?http://localhost:8080 ./entry/app.js
0 bytes {0} [built]
     + 261 hidden modules
webpack: Compiled successfully.

我的代码出了什么问题?

1 个答案:

答案 0 :(得分:0)

看起来您正在运行webpack-dev-server,它会编译您的软件包但不会将其写入磁盘(它会将其保留在内存中)。

您必须运行webpack才能获取输出文件。

webpack --config config/webpack.config.js