Exclude directory/files depending on build mode

I have searched and not found a working solution for this. Is it possible to exclude file and/or directories from compilation depending on the build mode used? I have an alternative main.ts, main.playground.ts. We use for rapid component dev. We also have a directory in src/components/playground. We add prototype/test code here. I would like to exclude these from the build when NODE_ENV is production. For the life of me I have not found a way to do it. Any ideas? Thanks in advance.

If you don’t use main.playground.ts as an entry point (or import it within any of your production components) I wouldn’t expect it to be part of the bundle. You can use NODE_ENV to conditionally handle parts of your code, but if the entry point is the only thing being swapped, again, I wouldn’t expect it to be included in production.

Hard to say without seeing any code/configuration though.

Yes is looks like main.playground.ts is not included but the components in the playground appear to be included. I would like to know how to eliminate the compilation and bundling of src/components/Playground/*

The config is as follows:

const config = {
  filenameHashing: false,
  transpileDependencies: ["vuetify", "luxon"],
  productionSourceMap: false,
  pages: {
    index: {
      entry: ["./src/main.ts"]
    }
  },
  configureWebpack: {
    devtool: "source-map",
    devServer: {
      open: true
    },
    plugins: [new BannerPlugin({ banner: banner })],
    resolve: {
      alias: {
        "@": resolve("src"),
        "@Services": resolve("src/shared/services")
      }
    }
  }
};

if (process.env.NODE_ENV === "playground") {
  config.pages.index.entry = ["./src/main.playground.ts"];
}

module.exports = config;

My assumption is that somewhere those components are accessible from the entry as a dependency. Based on how Webpack works (by starting at the entry and walking through all the imported dependencies) this is my only logical explanation.

Thanks, you are correct. My global registration logic bit me on this one. It was staring me in the face the entire time. Thanks for helping me open my eyes.