2018-05-18 16:10:52 +00:00
|
|
|
const path = require("path");
|
|
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
|
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
// Defaults
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
|
|
|
const defaults = {
|
|
|
|
mode : "development",
|
|
|
|
context : __dirname,
|
|
|
|
entry : {
|
2019-07-11 04:21:20 +00:00
|
|
|
Tone : "./Tone/index.ts",
|
2018-05-18 16:10:52 +00:00
|
|
|
},
|
|
|
|
output : {
|
|
|
|
path : path.resolve(__dirname, "build"),
|
|
|
|
filename : "[name].js",
|
2019-07-11 15:05:03 +00:00
|
|
|
library: "Tone",
|
2019-08-30 16:04:31 +00:00
|
|
|
libraryTarget : "umd"
|
2018-05-18 16:10:52 +00:00
|
|
|
},
|
|
|
|
resolve : {
|
2019-08-26 17:55:04 +00:00
|
|
|
extensions: ['.ts', '.js']
|
2019-07-11 04:21:20 +00:00
|
|
|
},
|
|
|
|
module : {
|
|
|
|
rules : [
|
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
use: 'ts-loader',
|
|
|
|
exclude: /(node_modules)/,
|
|
|
|
}
|
|
|
|
]
|
2018-05-18 16:10:52 +00:00
|
|
|
},
|
|
|
|
devtool : "cheap-source-map",
|
|
|
|
};
|
|
|
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
// Scratch
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
|
|
|
const scratch = Object.assign({}, defaults, {
|
|
|
|
entry : {
|
2019-07-19 16:33:15 +00:00
|
|
|
scratch : "./examples/scratch.ts",
|
2018-05-18 16:10:52 +00:00
|
|
|
},
|
|
|
|
plugins : [
|
2019-01-10 03:43:42 +00:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template : "./examples/scratch.html"
|
|
|
|
})
|
2018-05-18 16:10:52 +00:00
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
};
|