【发布时间】:2019-03-24 21:32:45
【问题描述】:
我的代码有一些问题。我正在尝试将 babel-loader 添加到我的 laravel-mix webpack 的配置中,但我收到一条错误消息,告诉我 this.setDynamic 不是函数。
这是我的 webapack-mix.js 文件
const {mix} = require('laravel-mix');
const VueLoaderPlugin = require('vue-loader/lib/plugin')
/*
|--------------------------------------------------------------------------
| 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.webpackConfig({
module: {
rules: [
// We're registering the TypeScript loader here. It should only
// apply when we're dealing with a `.ts` or `.tsx` file.
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: {appendTsSuffixTo: [/\.vue$/]},
exclude: /node_modules/,
},
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: ["@babel/plugin-transform-runtime"],
}
},
}
],
},
plugins: [
// make sure to include the plugin!
new VueLoaderPlugin()
],
resolve: {
// We need to register the `.ts` extension so Webpack can resolve
// TypeScript modules without explicitly providing an extension.
// The other extensions in this list are identical to the Mix
// defaults.
extensions: ['*', '.jsx', '.vue', '.ts', '.tsx', '.js'],
},
});
mix.sass('resources/sass/app.scss', 'public/css')
.sass('resources/sass/admin.scss', 'public/css')
.ts('resources/js/src/app.ts', 'public/js')
.ts('resources/js/src/Admin/admin.ts', 'public/js')
有人对此有解决方案吗?我在互联网上做了很多研究,但没有任何效果
【问题讨论】:
-
我在尝试使用材料组件时得到了同样的结果。找到解决办法了吗?
标签: webpack vuejs2 babeljs laravel-mix babel-loader