Files
spark/src/web/ui/webpack.config.js
T

93 lines
2.5 KiB
JavaScript

var path = require("path");
var webpack = require("webpack");
var fableUtils = require("fable-utils");
var mod = require("@babel/preset-env")
// var UglifyJsPlugin = require("uglifyjs-webpack-plugin")
function resolve(filePath) {
return path.join(__dirname, filePath)
}
var babelOptions = {
presets: ["@babel/preset-env"],
// "presets": [
// "@babel/preset-env", "@babel/preset-react"
// ],
plugins: [
[
"@babel/plugin-transform-runtime",
{
helpers: true,
// We don't need the polyfills as we're already calling
// cdn.polyfill.io/v2/polyfill.js in index.html
regenerator: false,
},
],
],
};
var isProduction = process.argv.indexOf("-p") >= 0;
process.env.NODE_ENV = isProduction ? 'production' : 'development'
console.log("Bundling for " + (isProduction ? "production" : "development") + "...");
module.exports = env => {
const build_path = (env||{}).BUILD_PATH || resolve("../../../build/web")
const output_path = build_path + "/ui/";
const api_path = build_path + "/api/";
return {
devtool: isProduction ? undefined : "source-map",
entry: resolve('./src/ui.fsproj'),
output: {
filename: 'bundle.js',
path: output_path,
},
resolve: {
modules: [
"node_modules", resolve("./node_modules/"), api_path
]
},
devServer: {
contentBase: resolve("./public/"),
port: 8080,
hot: true,
inline: true
},
module: {
rules: [
{
test: /\.fs(x|proj)?$/,
use: {
loader: "fable-loader",
options: {
babel: babelOptions,
define: isProduction ? [] : ["DEBUG"]
}
}
},
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: babelOptions
},
},
{
test: /\.scss$/,
use: [
"style-loader",
"css-loader",
"sass-loader"
]
}
]
},
// plugins: isProduction ? [new UglifyJsPlugin()] : [
// new webpack.HotModuleReplacementPlugin(),
// new webpack.NamedModulesPlugin()
// ]
plugins: [
new webpack.HotModuleReplacementPlugin()
]
}};