Files
discord.js/webpack.config.js
Gus Caplan 6ce9a8743f update browser stuff and browser eslint (#1938)
* Update browser.js

* Update .eslintrc.json

* Update package.json

* Update package.json

* stop doing manually what webpack can do for us

* Update .eslintrc.json

* Update package.json
2017-09-24 21:01:47 +01:00

55 lines
1.3 KiB
JavaScript

/*
ONLY RUN BUILDS WITH `npm run webpack`!
DO NOT USE NORMAL WEBPACK! IT WILL NOT WORK!
*/
const webpack = require('webpack');
const createVariants = require('parallel-webpack').createVariants;
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const version = require('./package.json').version;
const createConfig = options => {
const plugins = [
new webpack.DefinePlugin({ 'global.GENTLY': false }),
new webpack.optimize.ModuleConcatenationPlugin(),
];
if (options.minify) {
plugins.push(new UglifyJSPlugin({
uglifyOptions: {
mangle: { keep_classnames: true },
output: { comments: false },
},
}));
}
const filename = `./webpack/discord${process.env.VERSIONED === 'false' ? '' : '.' + version}${options.minify ? '.min' : ''}.js`; // eslint-disable-line
return {
entry: './src/index.js',
output: {
path: __dirname,
filename,
library: 'Discord',
libraryTarget: 'window',
},
module: {
rules: [
{ test: /\.md$/, loader: 'ignore-loader' },
],
},
node: {
fs: 'empty',
dns: 'mock',
tls: 'mock',
child_process: 'empty',
dgram: 'empty',
zlib: 'empty',
__dirname: true,
},
plugins,
};
};
module.exports = createVariants({}, { minify: [false, true] }, createConfig);