如何在laravel 5.5应用程序中包含/ node_modules,我引用了这个https://laravel.com/docs/5.5/mix
我能做到这一点
npm install angular-moment moment --save
它将创建一个/ node_modules目录,但是laravel会忽略它
我想说我想这样做
<script src="node_modules/moment/moment.js"></script>
它不起作用,它会显示错误
我目前在我的webpack中有这个,这将是集成它的最佳方式吗?
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.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css');
答案 0 :(得分:10)
只需将其包含在您的app.js中,即可遵守...
var moment = require('moment');
然后访问它......就像
一样moment().format();