1.0.0 • Published 4 years ago

egg-webpack-assets v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

egg-webpack-assets

开启插件

// {app_root}/config/plugin.js
exports.webpackAssets = {
  enable: true,
  package: 'egg-webpack-assets',
};

使用场景

webpack AssetsPlugin 插件生成的json文件,在 egg 框架视图层直接使用 assets 变量。

例如:

// xx.html
{% if assets['vendor'] and assets['vendor'].css %}<link href="{{ assets['vendor'].css}}" rel="stylesheet">{% endif %}

详细配置

// {app_root}/config/config.default.js
'use strict';
const path = require('path');

module.exports = appInfo => {
  return {
    webpackAssets: {
      file: path.join(appInfo.baseDir, 'app', 'assets.json'), // webpack AssetsPlugin插件生成的json文件路径
    },
  };
};

单元测试

License

MIT