mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 00:27:58 +00:00
83 lines
1.5 KiB
JavaScript
83 lines
1.5 KiB
JavaScript
const path = require("path");
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
|
|
// /////////////////////////////////////
|
|
// Defaults
|
|
// /////////////////////////////////////
|
|
|
|
const defaults = {
|
|
mode: "development",
|
|
context: __dirname,
|
|
entry: {
|
|
Tone: "./Tone/index.ts",
|
|
},
|
|
output: {
|
|
path: path.resolve(__dirname, "build"),
|
|
filename: "[name].js",
|
|
library: "Tone",
|
|
libraryTarget: "umd"
|
|
},
|
|
resolve: {
|
|
extensions: [".ts", ".js"]
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.ts$/,
|
|
use: "ts-loader",
|
|
exclude: /(node_modules)/,
|
|
}
|
|
]
|
|
},
|
|
devtool: "cheap-source-map",
|
|
};
|
|
|
|
// /////////////////////////////////////
|
|
// Scratch
|
|
// /////////////////////////////////////
|
|
|
|
const scratch = Object.assign({}, defaults, {
|
|
entry: {
|
|
scratch: "./examples/scratch.ts",
|
|
},
|
|
plugins: [
|
|
new HtmlWebpackPlugin({
|
|
template: "./examples/scratch.html"
|
|
})
|
|
],
|
|
});
|
|
|
|
// /////////////////////////////////////
|
|
// Tests
|
|
// /////////////////////////////////////
|
|
|
|
const test = Object.assign({}, defaults, {
|
|
entry: {
|
|
test: "./test/test.js",
|
|
},
|
|
plugins: [
|
|
new HtmlWebpackPlugin({
|
|
filename: "test.html",
|
|
template: "./test/index.html",
|
|
})
|
|
],
|
|
});
|
|
|
|
// /////////////////////////////////////
|
|
// Production
|
|
// /////////////////////////////////////
|
|
|
|
const production = Object.assign({}, defaults, {
|
|
mode: "production",
|
|
devtool: "source-map",
|
|
});
|
|
|
|
module.exports = env => {
|
|
if (env.test) {
|
|
return test;
|
|
} else if (env.production) {
|
|
return production;
|
|
} else {
|
|
return scratch;
|
|
}
|
|
};
|