1.0.7 • Published 4 years ago

auto-inject-loader v1.0.7

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

用法

在webpack配置里面加

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        include: [resolve('src')],
        use: ['thread-loader', 'cache-loader', {
          loader: 'babel-loader',
        }, {
          loader: 'auto-inject-loader',
          options: {
            autoImport: [
              {
                name: 'localSocket',
                paths: 'src/lib/core/index.js'
              }
            ]
          }
        }]
      }
    ]
  }
}

auto-inject-loader

Options

autoImport

Type: Array name: 当前在页面使用的变量 paths: 变量定义所在哪个文件路径下

eg:

会在js部分生成如下

import localSocket from 'src/lib/core/index.js'

注意事项: 1. 如果项目使用了eslint校验,需要在eslintrc.js 添加

globals: {
  localSocket: true // 此处localSocket即是在options里面定义的name
}
1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago