Tone.js/scripts/webpack.config.cjs

56 lines
1 KiB
JavaScript
Raw Normal View History

/* eslint-disable @typescript-eslint/no-var-requires */
2018-05-18 16:10:52 +00:00
const path = require("path");
2019-09-16 18:03:52 +00:00
// /////////////////////////////////////
2018-05-18 16:10:52 +00:00
// Defaults
2019-09-16 18:03:52 +00:00
// /////////////////////////////////////
2018-05-18 16:10:52 +00:00
const defaults = {
2019-09-16 18:03:52 +00:00
mode: "development",
context: __dirname,
entry: {
Tone: "../Tone/index.ts",
2018-05-18 16:10:52 +00:00
},
2019-09-16 18:03:52 +00:00
output: {
path: path.resolve(__dirname, "../build"),
2019-09-16 18:03:52 +00:00
filename: "[name].js",
library: "Tone",
libraryTarget: "umd",
globalObject: "typeof self !== 'undefined' ? self : this",
2018-05-18 16:10:52 +00:00
},
2019-09-16 18:03:52 +00:00
resolve: {
extensionAlias: {
".js": [".js", ".ts"],
},
2019-07-11 04:21:20 +00:00
},
2019-09-16 18:03:52 +00:00
module: {
rules: [
2019-07-11 04:21:20 +00:00
{
test: /\.ts$/,
2019-09-16 18:03:52 +00:00
use: "ts-loader",
2019-07-11 04:21:20 +00:00
exclude: /(node_modules)/,
},
],
2018-05-18 16:10:52 +00:00
},
2019-09-16 18:03:52 +00:00
devtool: "cheap-source-map",
2018-05-18 16:10:52 +00:00
};
2019-09-16 18:03:52 +00:00
// /////////////////////////////////////
2018-05-18 16:10:52 +00:00
// Production
2019-09-16 18:03:52 +00:00
// /////////////////////////////////////
2018-05-18 16:10:52 +00:00
const production = Object.assign({}, defaults, {
2019-09-16 18:03:52 +00:00
mode: "production",
devtool: "source-map",
2018-05-18 16:10:52 +00:00
});
module.exports = (env) => {
2019-09-16 18:03:52 +00:00
if (env.test) {
2018-05-18 16:10:52 +00:00
return test;
2019-09-16 18:03:52 +00:00
} else if (env.production) {
2018-05-18 16:10:52 +00:00
return production;
} else {
2020-05-07 13:26:49 +00:00
return scratch;
2018-05-18 16:10:52 +00:00
}
};