【发布时间】:2021-04-09 14:13:49
【问题描述】:
我正在尝试使用 webpack 和 typescript 设置 vue3。
目前我遇到的问题是每当我尝试运行webpack serve时,浏览器控制台内都会出现警告:
runtime-core.esm-bundler.js:3413 You are running the esm-bundler build of Vue. It is recommended to configure your bundler to explicitly replace feature flag globals with boolean literals to get proper tree-shaking in the final bundle. See http://link.vuejs.org/feature-flags for more details.
我不明白。我的 webpack-config 如下:
const path = require("path")
module.exports = {
mode: 'development',
entry: './src/index.ts',
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
alias: {
vue: "vue/dist/vue.esm-bundler.js"
},
extensions: ['.tsx', '.ts', '.js'],
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
}
这是 tsconfig:
{
"compilerOptions": {
"outDir": "./dist/",
"noImplicitAny": true,
"module": "es6",
"target": "es5",
"allowJs": true,
"moduleResolution": "node"
}
}
我想在没有此警告的情况下进行配置,然后继续支持 sfc!
【问题讨论】:
-
查看本教程以了解没有 vue-cli 的 Vue v3 设置:frontendguruji.com/blog/…