尝试在Laravel项目中使用反应。
我已经npm install
我的webpack.mix.js文件是mix.react('resources/assets/js/app.js', 'public/js');
并运行npm run dev
给我一个错误
/Users/jacobchen/www/fusion2/webpack.mix.js:14
mix.react('resources/assets/js/app.js', 'public/js');
^
TypeError: mix.react is not a function
webpack.mix.js
const { mix } = require('laravel-mix');
mix.react('resources/assets/js/app.js', 'public/js');
有人有过这方面的经验吗?
最好的问候
雅各
答案 0 :(得分:0)
您还需要在package.json
的npm脚本部分中设置laravel-mix。
来自Laravel的package.json
:
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
完整示例如下: https://github.com/laravel/laravel/blob/master/package.json