[英]Find right solution to include React + TypeScript at the same time in Laravel Mix webpack.mix?
当我尝试连接时:
mix.ts('resources/assets/js/app.ts', 'public/js/app.js') .react('resources/js/app.ts', 'public/js/app.js');
出现错误:
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.
所以,我是这样解决的:
`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'],
},
})`
但我不确定它是否正确,有什么建议吗??? 我会很高兴的,谢谢)
现在回答为时已晚,但它可能对遇到相同问题的人有所帮助。
webpack.mix.js:
mix.ts('resources/js/index.tsx', 'public/js/app.js').react();
在 Laravel 刀片模板中关闭 body 标签之前放置以下脚本标签:
<script src="{{ asset('js/app.js') }}"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.