snowpack.config.js 1.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
/* eslint-disable @typescript-eslint/no-var-requires */

require('./builder/environment');
const mock = require('./builder/mock');
const icons = require('./builder/icons');
const netron = require('./builder/netron');
const wasm = require('./builder/wasm');

const port = Number.parseInt(process.env.PORT || 3000, 10);
const devServer = {
    port: port + 1,
    host: '127.0.0.1'
};

module.exports = {
    extends: '@snowpack/app-scripts-react',
    plugins: [
        '@snowpack/plugin-dotenv',
        [
            '@snowpack/plugin-run-script',
            {
                cmd: 'node builder/icons.js && node builder/netron.js && node builder/wasm.js',
                watch: `node builder/dev-server.js --port ${devServer.port} --host ${devServer.host}`,
                output: 'dashboard'
            }
        ]
    ],
    install: ['@visualdl/wasm'],
    alias: {
        '~': './src'
    },
    proxy: {
        ...[mock.pathname, icons.pathname, netron.pathname, wasm.pathname].reduce((m, pathname) => {
34 35 36
            m[
                process.env.SNOWPACK_PUBLIC_BASE_URI + pathname
            ] = `http://${devServer.host}:${devServer.port}${pathname}`;
37 38 39 40 41 42 43 44 45
            return m;
        }, {})
    },
    devOptions: {
        out: 'dist',
        hostname: process.env.HOST || 'localhost',
        port
    },
    buildOptions: {
46
        baseUrl: process.env.SNOWPACK_PUBLIC_PATH || '/',
47 48 49 50 51 52 53
        clean: true
    },
    installOptions: {
        polyfillNode: true,
        namedExports: ['file-saver']
    }
};