webpack4 基本设置应用示例 (Nodejs -v10)

目录结构

dist
|  font
|  |  ...
|  images
|  |  ...
|  js
|  |  index.js
|  css
|  |  styles.css
node_modules
src
|  font
|  |  ...
|  images
|  |  ...
|  js
|  |  module
|  |  |  loading.js
|  |  |  ...
|  |  index.js
|  scss
|  |  base
|  |  |  ...
|  |  function
|  |  |  ...
|  |  layout
|  |  |  ...
|  |  mixin
|  |  |  ...
|  |  _variables.scss
|  |  styles.scss
package.json
webpack.config.js
webpack.config.entry.js(把需要编译的多个js入口单独写配置文件)

使用方法

npm install 安装命令(每个项目仅需执行一次)
npm run-script build 编译一次,并压缩文件
npm start 编译并启动监听

Read more