3

I want webpack to compile my typescript node project into js but I want it to maintain the directory structure and not bundle into 1 file.

Is this possible?

My structure is:

src
   |_controllers
     |_home
       |_index.ts
   |_ services
    // etc.

And I want it to compile to:

dist
   |_controllers
     |_home
       |_index.ts
   |_ services
    // etc.

currently my config is like this:

{
    name: 'api',
    target: 'node',
    externals: getExternals(),
    entry: isDevelopment ? [...entries] : entries,
    devtool: !isDevelopment && 'cheap-module-source-map',
    output: {
      path: paths.appBuild,
      filename: '[name].js',
      libraryTarget: 'commonjs2'
    },
    plugins: [
      new WriteFilePlugin(),
      new webpack.optimize.LimitChunkCountPlugin({
        maxChunks: 1
      }),
      isProduction && new webpack.optimize.ModuleConcatenationPlugin()
    ]
  }

Is it possible with webpack?

I can't use just tsc because I have a yarn workspaces monorepo and I might have a link reference like this:

import {something} from '@my/package';

@my/package does not exist in npm and only exists in the context of the monorepo, I can use node externals with webpack to include it in the bundle I don't think I can keep the folder structure this way.

Would the new typescript 3.0 project references solve this problem?

4

0 に答える 0