2 // Copyright 2020 Blue Static <https://www.bluestatic.org>
3 // This program is free software licensed under the GNU General Public License,
4 // version 3.0. The full text of the license can be found in LICENSE.txt.
5 // SPDX-License-Identifier: GPL-3.0-only
7 const path = require('path');
8 const webpack = require('webpack');
9 const WebpackDevServer = require('webpack-dev-server');
11 const isTypescript = process.argv[1].endsWith('ts');
13 const args = process.argv.slice(2);
14 if (args.length != 1) {
15 throw new Error('Usage: ustaxviewer path/to/taxreturn');
18 const TAX_RETURN_PATH = path.resolve(args[0]);
21 let r = path.resolve(__dirname, '..');
22 return isTypescript ? r : path.resolve(r, '..');
24 const DISTROOT = path.resolve(__dirname);
25 const PUBLIC = path.resolve(ROOT, 'public');
28 loader: 'babel-loader',
29 options: { presets: [ require('babel-preset-solid') ] }
32 const compiler = webpack({
34 main: path.resolve(DISTROOT, isTypescript ? 'main.tsx' : 'main.jsx')
39 mode: isTypescript ? 'development' : 'production',
42 extensions: [ '.tsx', '.ts', '.jsx', '.js' ],
70 localsConvention: 'camelCaseOnly',
72 localIdentName: '[path][name]_[local]_[hash:base64:2]'
82 filename: '[name].bundle.js',
83 chunkFilename: '[name].bundle.js',
94 hints: isTypescript ? 'warning' : false
100 path.dirname(require.resolve('@hpcc-js/wasm')),
106 devtool: 'eval-cheap-module-source-map',
109 new (require('html-webpack-plugin'))({
111 template: path.resolve(PUBLIC, 'index.html')
113 new webpack.DefinePlugin({
114 TAX_RETURN_PATH: JSON.stringify(TAX_RETURN_PATH),
119 const server = new WebpackDevServer(compiler, compiler.options.devServer);
121 server.listen(8488, 'localhost', () => {
122 console.log(`ustaxviewer for ${TAX_RETURN_PATH} at http://localhost:8488`);