For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/rspeedy/rspeedy.dev.assetprefix.md.
Rspeedy logo
Rspeedy
  • English
  • Home > @lynx-js/rspeedy > Dev > assetPrefix

    Dev.assetPrefix property

    The Dev.assetPrefix is used to set the URL prefix for static assets during development.

    Signature:

    assetPrefix?: string | boolean | undefined;

    Default Value

    undefined

    Remarks

    During rspeedy dev, if this option is not set to false, the dev plugin normalizes it to http://<detected-host>:<port>/ and appends server.base when configured.

    The functionality of Dev.assetPrefix is basically the same as the output.publicPath config in Rspack. With the following differences:

    • dev.assetPrefix only takes effect during development.

    • dev.assetPrefix automatically appends a trailing / by default.

    • The value of dev.assetPrefix is written to the process.env.ASSET_PREFIX environment variable.

    Example 1

    If dev.assetPrefix is set to true, the URL prefix will be http://<host>:<port>/:

    import { defineConfig } from '@lynx-js/rspeedy'
    export default defineConfig({
      dev: {
        assetPrefix: true,
      },
    })

    Example 2

    If dev.assetPrefix is set to a string, the value will be used as a prefix and automatically appended to the static resource URL.

    import { defineConfig } from '@lynx-js/rspeedy'
    export default defineConfig({
      dev: {
        assetPrefix: 'https://example.com/assets/',
      },
    })

    Example 3

    The port number that Rspeedy server listens on may change. For example, if the port is in use, Rspeedy will automatically increment the port number until it finds an available port.

    To avoid dev.assetPrefix becoming invalid due to port changes, you can use one of the following methods:

    • Enable server.strictPort.

    • Use the <port> placeholder to refer to the current port number. Rspeedy will replace the placeholder with the actual port number it is listening on.

    import { defineConfig } from '@lynx-js/rspeedy'
    export default defineConfig({
      dev: {
        assetPrefix: 'https://example.com:<port>/assets/',
      },
    })
    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.