Laravel Mix-JS作为ES2016

时间:2019-02-25 17:39:21

标签: webpack laravel-mix

默认情况下(用于生产),Laravel Mix将JS转换为ES5。我希望能够对其进行管理并根据需要将其关闭。这是我的文件:

webpack.mix.js:

let mix = require('laravel-mix');

mix.disableNotifications();
mix.setPublicPath('./');

mix.js([
  '_dev/js/Core.js'
], 'public/dist/js/scripts.js');

_dev / js / Core.js:

class Core {

  constructor()
  {
    console.log('Hello World!');
  }

}

new Core();

package.json:

{
  "private": true,
  "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": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --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 --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "browserslist": [
    "chrome 60",
    "firefox 55",
    "safari 11"
  ],
  "devDependencies": {
    "cross-env": "^5.2.0",
    "laravel-mix": "^1.0"
  }
}

我可以通过某种方式更改预设吗?理想情况下,Babel会考虑浏览器列表并根据它们来转换JS。例如,如果我有IE11,则为ES2015,否则为ES2016。

Laravel Mix的Autoprefixer支持浏览器列表,并能引起轰动!

提前感谢您的帮助!

0 个答案:

没有答案