DI-compiler icon indicating copy to clipboard operation
DI-compiler copied to clipboard

Usage with Vite.js

Open kien8995 opened this issue 3 years ago • 2 comments

How i can use DI-compiler with Vite.js ?

kien8995 avatar Jan 24 '22 07:01 kien8995

I've written a simple vite plugin applying the transformers:

const { di } = require('@wessberg/di-compiler');
const typescript = require('rollup-plugin-ts');

module.exports = function (options = {}) {
  return {
    name: 'vite:di',
    enforce: 'pre',
    ...typescript({
      ...options,
      transformers: [di],
      transpileOnly: true,
      exclude: ['**/*.test.ts'],
      tsconfig: (resolvedConfig) => ({ ...resolvedConfig, declaration: false }),
    }),
  };
};

Adjust options and config to your needs and you should be good to go.

arm1n avatar Jan 04 '23 07:01 arm1n

If someone needs a full setup example, here it is.

i7N3 avatar Mar 12 '23 10:03 i7N3