2019-11-07 20:45:00 +00:00
|
|
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
2018-05-18 16:10:52 +00:00
|
|
|
const path = require("path");
|
|
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
|
|
|
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"),
|
|
|
|
filename: "[name].js",
|
2019-07-11 15:05:03 +00:00
|
|
|
library: "Tone",
|
2019-11-07 20:45:00 +00:00
|
|
|
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: {
|
|
|
|
extensions: [".ts", ".js"]
|
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
|
|
|
// Scratch
|
2019-09-16 18:03:52 +00:00
|
|
|
// /////////////////////////////////////
|
2018-05-18 16:10:52 +00:00
|
|
|
|
|
|
|
const scratch = Object.assign({}, defaults, {
|
2019-09-16 18:03:52 +00:00
|
|
|
entry: {
|
|
|
|
scratch: "./examples/scratch.ts",
|
2018-05-18 16:10:52 +00:00
|
|
|
},
|
2019-09-16 18:03:52 +00:00
|
|
|
plugins: [
|
2019-01-10 03:43:42 +00:00
|
|
|
new HtmlWebpackPlugin({
|
2019-09-16 18:03:52 +00:00
|
|
|
template: "./examples/scratch.html"
|
2019-01-10 03:43:42 +00:00
|
|
|
})
|
2018-05-18 16:10:52 +00:00
|
|
|
],
|
|
|
|
});
|
|
|
|
|
2019-09-16 18:03:52 +00:00
|
|
|
// /////////////////////////////////////
|
2018-05-18 16:10:52 +00:00
|
|
|
// Tests
|
2019-09-16 18:03:52 +00:00
|
|
|
// /////////////////////////////////////
|
2018-05-18 16:10:52 +00:00
|
|
|
|
|
|
|
const test = Object.assign({}, defaults, {
|
2019-09-16 18:03:52 +00:00
|
|
|
entry: {
|
|
|
|
test: "./test/test.js",
|
2018-05-18 16:10:52 +00:00
|
|
|
},
|
2019-09-16 18:03:52 +00:00
|
|
|
plugins: [
|
2018-05-18 16:10:52 +00:00
|
|
|
new HtmlWebpackPlugin({
|
2019-09-16 18:03:52 +00:00
|
|
|
filename: "test.html",
|
|
|
|
template: "./test/index.html",
|
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
|
|
|
}
|
|
|
|
};
|