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

223
Vistas
Compiling A Typescript Create React App to Import in another React App

I have a Create React App written in Typescript, I will call it MyApp. I want to run this App inside an already existing React App, I will call it ExistingApp.

I would like to use it as follows:

import App from "node_modules/@MyApp/src"

function ExistingApp() {
   return (
     <div className="App">
       <App />
     </div>
   );
}

export default ExistingApp;

I would like to do this compilation/Transpiling using Webpack. I would like the folder structure to be maintained without bundling everything into a single JS file. I have managed to achieve the desire outcome with

tsc --module commonjs --outDir dist

However my .scss files are not being copied to the dist folder. the dist folder only contains the transpilled js files.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The below solution is to get webpack to use Sass, with bundling. If you do not want bundling, I wouldn't use webpack at all.

In production, try:

  1. Install these packages with the following command
npm i --save-dev sass-loader node-sass mini-css-extract-plugin css-loader style-loader
  1. Add the following code snippet to your webpack config in the rules array (make sure to import MiniCssExtractPlugin in the config file)
{
     test: /\.(s(a|c)ss)$/,
     use: [MiniCssExtractPlugin.loader,'css-loader', 'sass-loader']
}

Import MiniCssExtractPlugin (put this at the top of the config):

import * as MiniCssExtractPlugin from "mini-css-extract-plugin"

OR

const MiniCssExtractPlugin = require("mini-css-extract-plugin")

In development, you can just do this

  1. Same thing as step one in example 1
  2. Use this code snippet instead, in the same place as example 1 (no need to import MiniCssExtractPlugin)
{
    test: /\.(s(a|c)ss)$/,
    use: ['style-loader','css-loader', 'sass-loader']
}

Source

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