Shenchuanhuan/hello-world

# webpack 配置学习笔记

Opened this issue · 0 comments

entry 入口配置

simple rule: one entry point per HTML page. SPA: one entry point, MPA: multiple entry points.
单页面应用单入口,多页面多入口。
值: string || array || object || (function(){return string || array || obj}())
命名:naming
如果配置的是一个 string || array,命名为main。如果传入的是一个对象,则键名为输入块的名字,键值为对应的入口文件。
动态入口配置:

entry: () => './demo'

or 

entry: () => new Promise((resolve) => resolve(['./demo', './demo2'])

output 出口配置

problems:

有关webpack.config.js中的resolve.alias配置问题:

environment: macOS Sierra, node: 7.6.0
wrong config:

      resolve: {
          alias: {
             Doc: path.resolve(__dirname, 'src/doc')
          }
      }

correct config:

      resolve: {
           alias: {
               doc: path.resolve(__dirname, 'src/doc')
          }
       }

summary: if use upper case, the compiler will warn your that :

WARNING in ./src/Model/request.js
There are multiple modules with names that only differ in casing.
This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
Use equal casing. Compare these module identifiers:
* /Users/XXX/Documents/dh/entity-lib/node_modules/babel-loader/lib/index.js!/Users/XXX/Documents/dh/entity-lib/src/Model/request.js
    Used by 1 module(s), i. e.
    /Users/XXX/Documents/dh/entity-lib/node_modules/babel-loader/lib/index.js!/Users/XXX/Documents/dh/entity-lib/src/components/calcName.js

and your styles will not resolve.