Babel动态导入和laravel-mix问题

时间:2019-03-01 13:03:32

标签: laravel webpack

运行npm run watch时,出现以下警告,使编译失败。

WARNING in ./resources/js/app.js 19:9-58
System.import() is deprecated and will be removed soon. Use import() instead.
For more info visit https://webpack.js.org/guides/code-splitting/
 @ multi ./resources/js/app.js ./resources/sass/app.scss /js/app[0]

这是我的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": "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"
    },
    "devDependencies": {
        "@babel/plugin-syntax-dynamic-import": "^7.2.0",
        "babel-eslint": "^8.2.6",
        "babel-plugin-dynamic-import-webpack": "^1.1.0",
        "babel-preset-env": "^1.7.0",
        "bootstrap": "^4.0.0",
        "cross-env": "^5.1",
        "laravel-mix": "^4.0.14",
        "popper.js": "^1.12",
        "resolve-url-loader": "^2.3.1",
        "sass": "^1.17.2",
        "sass-loader": "^7.1.0"
    },
    "dependencies": {
        "vue": "^2.6.7",
        "vue-template-compiler": "^2.6.7",
        "axios": "^0.18",
        "jquery": "^3.2",
        "lodash": "^4.17.4",
        "tomtom-sdk": "^1.0.0",
        "vue-moment": "^4.0.0",
        "vue-parallaxy": "^1.1.1",
        "vue2-datepicker": "^2.6.4",
        "vue2-editor": "^2.6.6",
        "vuex": "^3.1.0",
        "vuex-persistedstate": "^2.5.4"
    }
}

我的.babelrc文件当前位于我的.vscode文件夹中,如果那是最好的地方,则不知道...

{
    "plugins": ["@babel/plugin-syntax-dynamic-import"]
}

当然,如果我删除System.import进行导入,则会收到以下错误:

https://i.imgur.com/UEhxaOh.png

这对我来说没有多大意义,因为我已经将插件部分添加到了babelrc文件中...

1 个答案:

答案 0 :(得分:0)

您没有附加webpack.mix.js配置。但我认为您的问题将通过下面的链接解决。

Laravel-mix Webpack Public Path