大块列/索引[条目]中的错误
columns / index.js
缺少类型:commonjs的外部配置
当我将webpack版本更新为4时,我得到了。我找不到那意味着什么。我排除了es降级的原因
这是webpack.config.js
const utils = require('./utils')
const CopyWebpackExternalsManifest = require('copy-webpack-externals-manifest')
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { VueLoaderPlugin } = require('vue-loader')
module.exports = {
entry: utils.entry("./app/src/**/index.js"),
output: utils.output,
plugins: [
...utils.plugins,
new CopyWebpackExternalsManifest({
externals: [{
module: "lodash",
entry: ["lodash.min.js"],
export: {
root: "_",
commonjs2: 'lodash'
}
}, {
module: "jquery",
entry: ["dist/jquery.min.js"],
export: {
root: "$",
commonjs2: 'jquery'
}
}, {
module: "tinymce",
entry: ["tinymce.min.js"],
export: {
root: "tinymce",
commonjs2: 'tinymce'
},
assets: ["plugins", "themes/modern", "skins"]
}, {
module: "plupload",
entry: ["js/plupload.full.min.js"],
export: {
root: "plupload",
commonjs2: 'plupload'
},
assets: ["js/moxie.min.js"]
}, {
module: "moment",
entry: ["min/moment.min.js"],
export: {
root: "moment",
commonjs2: 'moment'
}
}, {
module: "vue",
entry: [utils.vueRuntimeByEnv],
export: {
root: "Vue",
commonjs2: 'vue'
}
}, {
module: "element-ui",
entry: ["lib/index.js", "lib/theme-chalk/index.css"],
export: {
root: "ELEMENT",
commonjs2: 'element-ui'
},
assets: ["lib/theme-chalk/fonts"]
}, {
module: "vue-echarts",
entry: ["dist/vue-echarts.js"],
export: {
root: "VueECharts",
commonjs2: 'vue-echarts'
}
}
]
}),
new VueLoaderPlugin
],
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
rules: [
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader"
]
}, {
test: /\.less/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
"less-loader"
]
}
],
preserveWhitespace: false,
postcss: [
require('autoprefixer')({
browsers: ['last 5 versions']
})
]
}
},
{
test: /\.js$/,
loader: 'babel-loader'
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader"
]
},
{
test: /\.less$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader"
]
},
{
test: /\.(png|jpg|gif|svg|woff|eot|ttf)$/,
loader: 'file-loader',
options: {
name: '[name].[hash:7].[ext]'
}
}
]
}
};
这是目标js:columns / index.js
import Vue from '../constructor';
import index from './index.vue';
new Vue({
el: '#app',
render: h => h(index),
});
答案 0 :(得分:1)
我找到了原因,发现我在wepback的配置中设置了输出的libraryTarget
libraryTarget: 'umd'
但在外部
externals: {
lodash: {
commonjs: 'lodash',
commonjs2: 'lodash',
amd: 'lodash',
root: '_'
}
}
我忘了设置commonjs,所以我添加了commonjs,问题就解决了