1

我是 webpack 的新手。我的情况是:我尝试使用 webpack 来管理 hello.js 文件。

你好.js

     function hello(str){
        alert(str); 
}

包.json

{
  "name": "webpackdemo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "webpack": "^4.1.1"
  }
}

当我使用

webpack hello.js hello.bundle.js

我在 webstorm 终端中遇到错误

ERROR in multi ./hello.js hello.bundle.js
Module not found: Error: Can't resolve 'hello.bundle.js' in 'D:\webpackDemo'
 @ multi ./hello.js hello.bundle.js
4

1 回答 1

1

看起来,文档已经过时了,但是使用-o标志(output.filename)像这样尝试:

webpack ./hello.js -o hello.bundle.js --mode development

用于--mode production生产。

于 2018-03-21T01:34:20.103 回答