javascript - Laravel + React (Typescript/Javascript) - 如何编译任何带有扩展文件(js、jsx、ts、tsx)的模块?
问题描述
我有文件:root.tsx
import React, { Component } from 'react'
import Container from './apps/Container'
import Wrap from './apps/Wrap'
export default class Root extends Component {
render() {
console.log('load root.tsx')
return (
<div>
aaaa
<Container />
<Wrap />
</div>
)
}
}
和文件 app.tsx:
import React from 'react'
import ReactDOM from 'react-dom'
import RootApplication from './root'
ReactDOM.render(<RootApplication />, document.getElementById('root'))
我已经尝试同时加载两个代码 webpack.mix.js
const mix = require('laravel-mix');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
*/
mix.react('resources/js/app.js', 'public/js')
.ts('resources/js/app.tsx ', 'public/js/')
.sass('resources/sass/app.scss', 'public/css');
但这是多余的。如何使用一行代码但可以从文件 js jsx ts tsx 加载模块
解决方案
推荐阅读
- r - RStudio 查看器错误:未找到“会话/viewhtml ....”
- mysql - pdo 准备好的语句以无效的参数号退出
- azure - Azure 容器实例的静态 IP 地址
- impala - 在 Superset 上启用 Impala 模拟
- python - 在数据框列中选择并显示某个值
- javascript - 带有搜索和输入的 HTML 下拉框
- scala - 如何使用 Ignite 创建我自己的 CacheStore 以在二进制模式下存储值 (setStoreKeepBinary(true))
- security - GRPC 中不同端点的多个 SSL/TLS 证书
- javascript - 重组对象数组的最佳方法
- pyinstaller - Pyinstaller:运行 .exe 时找不到模块