Skip to content

【插件】使用webpack对模块的前端资源进行编译

Notifications You must be signed in to change notification settings

ploverjs/plover-assets-webpack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

plover-assets-webpack

NPM version build status Test coverage

【插件】使用webpack对模块的前端JS资源进行编译。

使用说明

1. 安装插件和webpack

npm install --save plover-assets-webpack webpack

2. 配置

按约定应用的webpack配置存放在config/webpack.js。 模块可以有自己的webpack配置,一般用于通用模块。

应用webpack配置示例:

module.exports = {
  // 配置对modules目录下的前端js文件进行编译
  match: ['modules/**/*.js'],

  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          presets: ['es2015']
        }
      }
    ]
  },

  plugins: []
};


// 编译时生效的插件
if (process.env.PLOVER_ASSETS_BUILD) {
  const webpack = require('webpack');
  module.exports.plugins = exports.webpack.plugins.concat([
    new webpack.optimize.UglifyJsPlugin()
  ]);
}

About

【插件】使用webpack对模块的前端资源进行编译

Resources

Stars

Watchers

Forks

Packages

No packages published