Where to store and load custom application settings (js vs json)

  • I’d like to store my application settings in zSettings.js file which would stay readable after building an application.

    I use static folder but I have a feeling that export default in combination with import always transpile my zSettings.js, so even I change the content it has no influance on application.

    // statics/zSettings.js
    const zSettings = {
      "API": "localhost"
    export default zSettings

    In my .vue component:

    import zSettings from "../statics/zSettings.js" // editable settings file

    Could you help me how to treat custom settings inside .js files or should I keep my settings as .json (where I can not store my comments) and use Webpack with fs to copy it into statics?

    Additional info: Documentation says that “files in static/ are not processed by Webpack at all” but I found out that all my files are processed and compiled (.js files) into webpack files into dist/js folder and copied to statics but settings are used from compiled dist/js folder.

  • After three days of trying to find a way how to force webpack load .js file and not to compile it I gave up. Back to axios and json.

Log in to reply