snowpack.config.js 1.4 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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
/* 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) => {
            m[(process.env.PUBLIC_PATH || '') + pathname] = `http://${devServer.host}:${devServer.port}${pathname}`;
            return m;
        }, {})
    },
    devOptions: {
        out: 'dist',
        hostname: process.env.HOST || 'localhost',
        port
    },
    buildOptions: {
        baseUrl: process.env.PUBLIC_PATH || '/',
        clean: true
    },
    installOptions: {
        polyfillNode: true,
        namedExports: ['file-saver']
    }
};