如何在laravel 5.5应用程序中包含/ node_modules,我引用了这个https://laravel.com/docs/5.5/mix
我可以做这个
npm install angular-moment moment --save
Run Code Online (Sandbox Code Playgroud)
它将创建一个/ node_modules目录,但是laravel会忽略它
我想说我想这样做
<script src="node_modules/moment/moment.js"></script>
Run Code Online (Sandbox Code Playgroud)
它不会工作,它会显示错误
我目前在我的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');
Run Code Online (Sandbox Code Playgroud)
Ser*_*rge 13
只需将其包含在您的app.js中,即可遵守...
var moment = require('moment');
Run Code Online (Sandbox Code Playgroud)
然后访问它作为时刻......就像
moment().format();
Run Code Online (Sandbox Code Playgroud)