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' ],
53 exclude: /node_modules/,
61 exclude: /node_modules/,
71 localsConvention: 'camelCaseOnly',
73 localIdentName: '[path][name]_[local]_[hash:base64:2]'
87 devtool: 'cheap-module-eval-source-map',
90 new (require('html-webpack-plugin'))({
92 template: path.resolve(PUBLIC, 'index.html')
94 new webpack.DefinePlugin({
95 TAX_RETURN_PATH: JSON.stringify(TAX_RETURN_PATH),
100 const server = new WebpackDevServer(compiler, compiler.options.devServer);
102 server.listen(8488, 'localhost', () => {
103 console.log(`ustaxviewer for ${TAX_RETURN_PATH} at http://localhost:8488`);