This is a more appropriate name (it is a web app after all), especially now that we've renamed sparkcmd -> Spark.Console (a literal console app). The old name implies a parallel between the two apps that doesn't exist.
93 lines
2.3 KiB
JavaScript
93 lines
2.3 KiB
JavaScript
var path = require("path");
|
|
var webpack = require("webpack");
|
|
|
|
function resolve(filePath) {
|
|
return path.isAbsolute(filePath) ? filePath : path.join(__dirname, filePath)
|
|
}
|
|
|
|
var babelOptions = {
|
|
presets: ["@babel/preset-env"],
|
|
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 = process.env.SPARK_ADMIN_WEB_APP_OUTPUT_DIR
|
|
const output_path = build_path
|
|
const api_path = build_path
|
|
return {
|
|
watchOptions: {
|
|
ignored: "./**/*"
|
|
},
|
|
devtool: isProduction ? undefined : "source-map",
|
|
entry: resolve(`${output_path}/App.js`),
|
|
output: {
|
|
filename: 'bundle.js',
|
|
path: output_path,
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
api: `${build_path}/api`
|
|
},
|
|
modules: [
|
|
resolve("./node_modules/"), api_path
|
|
]
|
|
},
|
|
devServer: {
|
|
static: {
|
|
directory: resolve('./public')
|
|
},
|
|
port: 8080,
|
|
proxy: undefined,
|
|
hot: false,
|
|
// Configuration for the development server
|
|
// redirect requests that start with /api/* to the server on port 8085
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.([cm]?ts|tsx)$/,
|
|
use: [
|
|
"ts-loader"
|
|
]
|
|
},
|
|
{
|
|
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()
|
|
]
|
|
}};
|