2018-05-29 13:06:24 +02:00
|
|
|
/*eslint-env node*/
|
|
|
|
|
|
|
|
const path = require("path");
|
|
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
|
|
const webpack = require("webpack");
|
|
|
|
|
|
|
|
function config({ entry, outputDir, title, template, mode }) {
|
|
|
|
mode = mode || "development";
|
|
|
|
const result = {
|
|
|
|
mode,
|
|
|
|
entry,
|
|
|
|
output: {
|
|
|
|
filename: "index.js",
|
|
|
|
path: path.resolve(__dirname, "dist", outputDir),
|
|
|
|
publicPath: "/" + outputDir
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$|\.jsx$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: "babel-loader",
|
|
|
|
options: {
|
2019-03-09 13:40:56 +01:00
|
|
|
presets: [
|
|
|
|
["@babel/preset-env", { modules: false }],
|
|
|
|
"@babel/preset-react"
|
|
|
|
]
|
2018-05-29 13:06:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
use: [{ loader: "style-loader" }, { loader: "css-loader" }]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.wasm$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
type: "javascript/auto",
|
|
|
|
use: { loader: "bin-loader" }
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new webpack.ContextReplacementPlugin(/mocha\/lib/, "", false),
|
|
|
|
new HtmlWebpackPlugin(
|
|
|
|
Object.assign(
|
|
|
|
{
|
|
|
|
title,
|
|
|
|
meta: {
|
|
|
|
viewport: "width=device-width, initial-scale=1, shrink-to-fit=no"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
template ? { template } : {}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
],
|
2018-05-29 22:55:17 +02:00
|
|
|
// Mocha requires this
|
2018-05-29 13:06:24 +02:00
|
|
|
node: {
|
|
|
|
fs: "empty"
|
2018-05-29 22:55:17 +02:00
|
|
|
},
|
|
|
|
// Mocha requires this
|
|
|
|
performance: { hints: false }
|
2018-05-29 13:06:24 +02:00
|
|
|
};
|
|
|
|
if (mode === "development") {
|
|
|
|
result.devtool = "cheap-module-eval-source-map";
|
|
|
|
} else {
|
|
|
|
result.devtool = "source-map";
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = (env, argv) => [
|
|
|
|
config({
|
|
|
|
title: "WAForth",
|
|
|
|
template: "./src/shell/index.html",
|
|
|
|
entry: "./src/shell/index.js",
|
|
|
|
outputDir: "waforth",
|
|
|
|
mode: argv.mode
|
|
|
|
}),
|
|
|
|
config({
|
|
|
|
title: "WAForth Unit Tests",
|
|
|
|
template: "./tests/index.html",
|
|
|
|
entry: "./tests/index.js",
|
|
|
|
outputDir: "tests",
|
|
|
|
mode: argv.mode
|
|
|
|
}),
|
|
|
|
config({
|
2018-05-29 21:14:22 +02:00
|
|
|
title: "Benchmarks",
|
|
|
|
entry: "./tests/benchmarks/index.js",
|
|
|
|
outputDir: "benchmarks",
|
2018-05-29 13:06:24 +02:00
|
|
|
mode: argv.mode
|
|
|
|
})
|
|
|
|
];
|