mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 01:53:30 +01:00
wew
This commit is contained in:
@@ -1,68 +1,60 @@
|
||||
/*
|
||||
ONLY RUN BUILDS WITH `npm run webpack`!
|
||||
DO NOT USE NORMAL WEBPACK! IT WILL NOT WORK!
|
||||
*/
|
||||
|
||||
const path = require('path');
|
||||
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.optimize.ModuleConcatenationPlugin(),
|
||||
];
|
||||
const plugins = [
|
||||
new webpack.optimize.ModuleConcatenationPlugin(),
|
||||
];
|
||||
|
||||
if (options.minify) {
|
||||
plugins.push(new UglifyJSPlugin({
|
||||
uglifyOptions: {
|
||||
mangle: { keep_classnames: true },
|
||||
output: { comments: false },
|
||||
},
|
||||
}));
|
||||
}
|
||||
const prod = process.env.NODE_ENV === 'production';
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
const filename = `discord${process.env.VERSIONED === 'false' ? '' : `.${version}`}${options.minify ? '.min' : ''}.js`;
|
||||
|
||||
return {
|
||||
entry: './src/index.js',
|
||||
output: {
|
||||
path: path.resolve('./webpack'),
|
||||
filename,
|
||||
library: 'Discord',
|
||||
libraryTarget: 'window',
|
||||
if (prod) {
|
||||
plugins.push(new UglifyJSPlugin({
|
||||
uglifyOptions: {
|
||||
mangle: { keep_classnames: true },
|
||||
output: { comments: false },
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{ test: /\.md$/, loader: 'ignore-loader' },
|
||||
{
|
||||
test: require.resolve('./package.json'),
|
||||
use: {
|
||||
loader: 'json-filter-loader',
|
||||
options: {
|
||||
used: ['version', 'homepage'],
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
const filename = `discord${process.env.VERSIONED ? `.${version}` : ''}${prod ? '.min' : ''}.js`;
|
||||
|
||||
module.exports = {
|
||||
entry: './src/index.js',
|
||||
output: {
|
||||
path: path.resolve('./webpack'),
|
||||
filename,
|
||||
library: 'Discord',
|
||||
libraryTarget: 'umd',
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{ test: /\.md$/, loader: 'ignore-loader' },
|
||||
{
|
||||
test: require.resolve('./package.json'),
|
||||
use: {
|
||||
loader: 'json-filter-loader',
|
||||
options: {
|
||||
used: ['version', 'homepage'],
|
||||
},
|
||||
},
|
||||
...require('snekfetch/webpack.supplemental').rules,
|
||||
],
|
||||
},
|
||||
node: {
|
||||
fs: 'empty',
|
||||
dns: 'mock',
|
||||
tls: 'mock',
|
||||
child_process: 'empty',
|
||||
dgram: 'empty',
|
||||
__dirname: true,
|
||||
process: false,
|
||||
path: 'empty',
|
||||
Buffer: false,
|
||||
zlib: 'empty',
|
||||
},
|
||||
plugins,
|
||||
};
|
||||
},
|
||||
...require('snekfetch/webpack.supplemental').rules,
|
||||
],
|
||||
},
|
||||
node: {
|
||||
fs: 'empty',
|
||||
dns: 'mock',
|
||||
tls: 'mock',
|
||||
child_process: 'empty',
|
||||
dgram: 'empty',
|
||||
__dirname: true,
|
||||
process: false,
|
||||
path: 'empty',
|
||||
Buffer: false,
|
||||
zlib: 'empty',
|
||||
},
|
||||
plugins,
|
||||
};
|
||||
|
||||
module.exports = createVariants({}, { minify: [false, true] }, createConfig);
|
||||
|
||||
Reference in New Issue
Block a user