Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

205
Vistas
How to save WebPack output files to another place automatically after my project is built

We have a SDK project witch is depended by another two projects.

When we want to build whole application, firstly, we need to build SDK project and upload it. Then we can build another two projects after run npm install.

This time I want to add a script for developer. When I run the script in SDK project it I can save the built output files to another projects node_modules.

Here is my code.

package.json file:

{
  ...
  "scripts": {
    "build:dev": "webpack --mode=development",
    ...
  }
  ...
}

webpack.config.js file:

let config = {
  ...
  module: {
    rules: [
      {
        test:/\.tsx?$/,
        use: 'ts-loader',
        exclude: /node_modules/
      }
    ]
  }
  ...
}

module.exports = (env, argv) => {
  if(argv.mode === 'development') {
    // We put all the projects in one repo
    config.output.path = path.resolve(__dirname,'../another-project/node_modules/sdk/dist/bundle')
  }
}

And at last we set outDir in tsconfig.json.

The problem is:

  • How to change the output file path for typescript declaration files by WebPack arguments?
  • How to save all the file to two places one time?

I figure out the last problem by using webpack -env xxx && webpack -env xxx. I just run script twice, maybe someone has better idear.

Now just one qusetion:

  • How to set the output file path for typescript declaration files dynamically?
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

webpack.config.js file:

let config = {
  ...,
  module: {
    rules: [
      {
        test:/\.tsx?$/,
        use: 'ts-loader',
        options: {
          configFile: "tsconfig.server.json"
        }
      }
    ]
  },
  ...
}

Then I can change configFlie in webpack module.

about 4 years ago · Juan Pablo Isaza Denunciar

0

https://webpack.js.org/configuration/output/

module.exports = {
...
  output: {
    filename: "lib.js"
  }
...

Configuring the out dir in typescript will not help you because webpack is the one responsible for compilation and will only use typescript for compilation after outputting the files itself.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda