We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$ npm init $ npm install webpack --save-dev # 或者安装指定版本 $ npm install webpack@1.2.x --save-dev $ mkdir src && mv entry.js src
修改package.json
package.json
scripts: { "dev": "webpack --colors --progress --watch" }
解读
progress 编译进度 colors 编译产出的命令行颜色 watch 持续监听编译过程
webpack.config.js
创建webpack.config.js,该文件是webpack的配置文件,可以将webpack的相关配置都在该文件中配置。
var path = require('path'); module.exports = { entry: "./src/entry.js", output: { path: path.resolve(__dirname, './dist'), filename: "bundle.js" } };
index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Webpack 完全教程</title> </head> <body> <script src="./dist/bundle.js"></script> </body> </html>
执行npm
$ npm run dev
The text was updated successfully, but these errors were encountered:
webpack 的配置项主要包括以下几点:
const config = { entry: { }, output: { }, module: { }, resolve: { }, plugins: [ ], externals: { } }; module.exports = config;
另外,更多配置项可以参见webpack configuration
Sorry, something went wrong.
No branches or pull requests
webpack 集成 npm scripts
修改
package.json
解读
webpack.config.js
创建webpack.config.js,该文件是webpack的配置文件,可以将webpack的相关配置都在该文件中配置。
index.html
执行npm
The text was updated successfully, but these errors were encountered: