我花了将近两天的努力,但是当我在Apache2配置中设置域别名时,仍然无法使用Laravel Mix渲染React组件。
domain name : http://dev.propertydodo.ae
Alias /admin-panel /var/www/html/pdd-admin/public
complete path is http://dev.propertydodo.ae/admin-panel
To fetch api its working path is http://dev.propertydodo.ae/admin-panel/api/v1
下面是我的Laravel Mix配置。
let 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.webpackConfig({
module: {
rules: [
{
test: /\.js?$/,
exclude: /(node_modules|bower_components)/,
loaders: [
'babel-loader?presets[]=react,presets[]=es2015,presets[]=stage-0',
]
}
],
}
}).react('resources/assets/js/locations.js', 'public/js')
.react('resources/assets/js/dashboard.js', 'public/js')
.react('resources/assets/js/payment.js', 'public/js')
.sourceMaps()
.sass('resources/assets/sass/app.scss', 'public/css');
下面是index.blade.php,我在其中渲染location.js,这是Babel编译的React资产文件到单个JS文件。
<div id='locations' class="content-wrapper">
</div>
<script src="{{route('baseurl') . mix('js/locations.js') }}">
</script>
答案 0 :(得分:0)
我认为这足以链接您的js文件
<script src="{{mix('js/locations.js')}}">