Disable Bundling from Webpack

2020-07-26 03:44发布

I want to use webpack just as a typescript build tool, such that each typescript file is translated into 1 js file.

The webpack guide has this configuration:

module.exports = {
    entry: './app.tsx',
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                use: 'ts-loader',
                exclude: /node_modules/
            }
        ]
    },
    resolve: {
        extensions: ['.tsx', '.ts', '.js']
    },
    output: {
        filename: 'bundle.js',
        path: path.resolve(__dirname, 'dist')
    }
};

question: Is it possible to modify this such that

  • each ts file translates into 1 js file and (more compliated)
  • such that no bundling occurs, and no module-webpack-boilerplate is produced?

remarks:

  1. I know I can use tsc for that, but for some reasons I would like to use webpack if possible. I simplified my scenario.

  2. There is another question sounding like the very same but the answers there do not answer anything for me: How to disable bundling in Webpack for development?

标签: webpack
1条回答
时光不老,我们不散
2楼-- · 2020-07-26 04:37

I understand you want to forego bundling and use the loaders with Webpack. I myself had considered this to speed up my dev build process. However, I believe the question you linked to states the answer correctly: this is not currently possible. The best approach is to use the devtool property in the Webpack config to enable sourcemaps. An alternative would be to use Gulp or Grunt for the dev build if all you want is to process TypeScript.

查看更多
登录 后发表回答