Skip to content

Instantly share code, notes, and snippets.

@qdot
Created December 6, 2018 21:07
Show Gist options
  • Save qdot/5d7e4b3c78bb5910e52c042e64e34aab to your computer and use it in GitHub Desktop.
Save qdot/5d7e4b3c78bb5910e52c042e64e34aab to your computer and use it in GitHub Desktop.
Rollup config for Buttplug from TheOne on discord
import alias from 'rollup-plugin-strict-alias';
import typescript from 'rollup-plugin-typescript';
import vue from 'rollup-plugin-vue';
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import nodeGlobals from 'rollup-plugin-node-globals';
import uglify from 'rollup-plugin-uglify';
import { minify } from 'uglify-js';
import livereload from 'rollup-plugin-livereload';
import serve from 'rollup-plugin-serve';
import json from 'rollup-plugin-json';
import builtins from 'rollup-plugin-node-builtins';
const plugins = [
typescript({
typescript: require('typescript')
}),
alias({
vue: 'node_modules/vue/dist/vue.common.js'
}),
json({}),
nodeResolve({
jsnext: true,
main: true,
browser: true,
preferBuiltins: true
}),
commonjs({
namedExports: {
// left-hand side can be an absolute path, a path
// relative to the current directory, or the name
// of a module in node_modules
'node_modules/buttplug/dist/main/src/index.js': [
"ButtplugClient",
"ButtplugClientDevice",
"IButtplugConnector",
"ButtplugEmbeddedServerConnector",
"SYSTEM_MESSAGE_ID",
"DEFAULT_MESSAGE_ID",
"MAX_ID",
"ButtplugMessage",
"ButtplugDeviceMessage",
"ButtplugSystemMessage",
"Ok",
"Ping",
"Test",
"Error",
"DeviceInfo",
"DeviceListVersion0",
"DeviceInfoWithSpecifications",
"DeviceList",
"DeviceAddedVersion0",
"DeviceAdded",
"DeviceRemoved",
"RequestDeviceList",
"StartScanning",
"StopScanning",
"ScanningFinished",
"RequestLog",
"Log",
"RequestServerInfo",
"ServerInfo",
"FleshlightLaunchFW12Cmd",
"KiirooCmd",
"SingleMotorVibrateCmd",
"StopDeviceCmd",
"StopAllDevices",
"LovenseCmd",
"VorzeA10CycloneCmd",
"GenericMessageSubcommand",
"SpeedSubcommand",
"VibrateCmd",
"RotateSubcommand",
"RotateCmd",
"VectorSubcommand",
"LinearCmd",
"MessageAttributes",
"CheckMessage",
"FromJSON",
"GetSchemaVersion",
"ButtplugLogLevel",
"LogMessage",
"ButtplugLogger",
"ButtplugException",
"ButtplugInitException",
"ButtplugDeviceException",
"ButtplugMessageException",
"ButtplugPingException",
"ButtplugUnknownException",
"ButtplugServer",
"ButtplugDevice",
"IDeviceSubtypeManager",
"ButtplugBluetoothDevice",
"BluetoothDeviceInfo",
"BluetoothDevices",
"IBluetoothDeviceImpl"
]
}
}),
nodeGlobals(),
builtins(),
vue({
css: './dist/build.css'
})
];
const config = {
input: './src/main.ts',
output: { file: './dist/build.js', sourceMap: true, format: 'umd' },
plugins: plugins
};
const isProduction = process.env.NODE_ENV === `production`;
const isDevelopment = process.env.NODE_ENV === `development`;
if (isProduction) {
config.output.sourceMap = false;
config.plugins.push(uglify({}, minify));
}
if (isDevelopment) {
config.plugins.push(livereload());
config.plugins.push(
serve({
contentBase: '.',
port: 8080,
open: true
})
);
}
export default config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment