[英]Find right solution to include React + TypeScript at the same time in Laravel Mix webpack.mix?
When i try to connect:当我尝试连接时:
mix.ts('resources/assets/js/app.ts', 'public/js/app.js') .react('resources/js/app.ts', 'public/js/app.js');
There is mistake appears :出现错误:
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration.entry should be one of these: function | object { <key>: non-empty string | [non-empty string] } | non-empty string | [non-empty string] -> The entry point(s) of the compilation.
So, i resolve this like this:所以,我是这样解决的:
`mix.react('resources/js/index.js', 'public/js/app.js')
.webpackConfig({
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.ts', '.tsx'],
},
})`
But i'm not sure is it right, any suggestions ???但我不确定它是否正确,有什么建议吗??? i'll be glad, thanks)
我会很高兴的,谢谢)
It's too late to answer but it might help for who has same problem.现在回答为时已晚,但它可能对遇到相同问题的人有所帮助。
webpack.mix.js: webpack.mix.js:
mix.ts('resources/js/index.tsx', 'public/js/app.js').react();
Put the following script tag before closing body tag in your Laravel blade template:在 Laravel 刀片模板中关闭 body 标签之前放置以下脚本标签:
<script src="{{ asset('js/app.js') }}"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.