12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- /* global __dirname, require, module*/
- const path = require('path');
- const env = require('yargs').argv.env; // use --env with webpack 2
- const pkg = require('./package.json');
- let libraryName = pkg.name;
- let outputFile, mode;
- if (env === 'build') {
- mode = 'production';
- outputFile = libraryName + '.min.js';
- } else {
- mode = 'development';
- outputFile = libraryName + '.js';
- }
- const config = {
- mode: mode,
- entry: __dirname + '/src/index.js',
- devtool: mode === 'production' ? false : 'inline-source-map',
- output: {
- path: __dirname + '/lib',
- filename: outputFile,
- library: libraryName,
- libraryTarget: 'umd',
- umdNamedDefine: true,
- globalObject: "typeof self !== 'undefined' ? self : this"
- },
- module: {
- rules: [
- {
- test: /(\.js)$/,
- loader: 'babel-loader',
- exclude: /(node_modules)/
- },
- {
- test: /(\.js)$/,
- loader: 'eslint-loader',
- exclude: /node_modules/,
- options: {
- fix: true
- }
- }
- ]
- },
- resolve: {
- modules: [path.resolve('./node_modules'), path.resolve('./src')],
- extensions: ['.json', '.js']
- }
- };
- module.exports = config;
|