markdown Laravel 5.4:从gulp迁移到webpack
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown Laravel 5.4:从gulp迁移到webpack相关的知识,希望对你有一定的参考价值。
- Create a `webpack.mix.js` file in root directory:
```js
const { mix } = require('laravel-mix');
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css');
/* Optional: uncomment for bootstrap fonts */
// mix.copy('node_modules/bootstrap-sass/assets/fonts/bootstrap/','public/fonts/bootstrap');
```
- Delete `gulpfile.js`
- Replace `package.json` content with (don't forget to keep your own dependencies):
```json
{
"private": true,
"scripts": {
"dev": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"hot": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"production": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"axios": "^0.15.2",
"bootstrap-sass": "^3.3.7",
"jquery": "^3.1.0",
"laravel-mix": "^0.5.0",
"lodash": "^4.16.2",
"vue": "^2.0.1"
}
}
```
- Remove `require('vue-resource');` if present in `assets/js/bootstrap.js`
- Replace:
```js
Vue.http.interceptors.push((request, next) => {
request.headers.set('X-CSRF-TOKEN', Laravel.csrfToken);
next();
});
```
By:
```js
window.axios = require('axios');
window.axios.defaults.headers.common = {
'X-CSRF-TOKEN': window.Laravel.csrfToken,
'X-Requested-With': 'XMLHttpRequest'
};
```
- Run `yarn` (or `npm install`)
- Run `npm run watch`to start working.
以上是关于markdown Laravel 5.4:从gulp迁移到webpack的主要内容,如果未能解决你的问题,请参考以下文章
markdown PHP 5.6性能基准与Laravel 5.4上的PHP 7相比
从 5.4 升级后的 Laravel 419 发布请求
将 Laravel 从 5.3 升级到 5.4
从 Laravel 5.3 升级到 Laravel 5.4 并且空字段转换为 NULL
从 laravel 5.4 中删除 public
Laravel 5.4:无法从关系中检索数据