webpack

像平时一样写代码。

app.js

import bar from './bar';

bar();

bar.js

export default function bar() {
  //
}

用 webpack 打包。

webpack.config.js

module.exports = {
  entry: './app.js',
  output: {
    filename: 'bundle.js'
  }
}

page.html

<html>
  <head>
    ...
  </head>
  <body>
    ...
    <script src="bundle.js"></script>
  </body>
</html>

然后在命令行中执行 webpack 命令来创建 bundle.js 文件。

就是如此简单!

webpack 入门

Support the Team

Through contributions, donations, and sponsorship, you allow webpack to thrive. Your donations directly support office hours, continued enhancements, and most importantly, great documentation and learning material!