0.5.8 • Published 6 years ago

nej-loader v0.5.8

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

npm

  • webpack 能够识别 NEJ 模块化加载方式的 javascript 代码,使用 nej/define.js 改造而来;
  • 不建议用它来加载 NEJ 自身类库,请直接使用现有 NPM 模块: nej-commonjs
  • 支持 SourceMap,配置 webpack.config.js 中的 devtool 即可。
npm install nej-loader
const {join} = require('path');
const jsRoot = join(__dirname, 'src/main/webapp/src/javascript');
const nejRoot = join(__dirname, 'src/main/webapp/src/javascript/lib');
module.exports = {
  module: {
    rules: [
        { 
            test: /\.js$/, 
            exclude: /nej|lib|node_modules/,
            use: [{
                loader: 'nej-loader'
                options: {
                    alias: [
                        {
                            key: 'lib',
                            value: nejRoot,
                        }, {
                            key: 'pro',
                            value: jsRoot,
                        }
                    ], 
                    replaceArgs: {
                        'pro/lib/regularjs/dist/regular': 'Regular',
                    },
                    outputAlias: [
                        {
                            key: 'nej-commonjs',
                            value: nejRoot,
                        }
                    ],
                    isPatch: false
                }
            }],
        }
    ]
  }
};
字段名作用
alias替换目标代码 define(['{lib}base/klass']) 中的 lib 变量为对应值
replaceArgs替换目标代码 define(['pro/lib/regularjs/dist/regular'], funcion (R) {}) 为对应值Regular
outputAlias替换目标代码 require(${nejRoot}/a.js)nejRootnej-commonjs
isPatch是否启用 NEJ 的平台兼容功能
0.5.8

6 years ago

0.5.7

6 years ago

0.5.6

7 years ago

0.5.5

7 years ago

0.5.4

7 years ago

0.5.2

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago