Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

202
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda