我目前正在设置一个vue 2应用程序与vite。
我收到这个错误。我想在vue 2中设置项目。我知道它是为vue 3构建的,但我是否遗漏了什么?
vite配置
import { minifyHtml, injectHtml } from 'vite-plugin-html'
import legacy from '@vitejs/plugin-legacy'
const path = require('path')
const { createVuePlugin } = require('vite-plugin-vue2')
module.exports = {
plugins: [
createVuePlugin(),
minifyHtml(),
injectHtml({
injectData: {
title: 'ProjectName',
description: 'A single page application created using Vue.js'
}
}),
legacy({
targets: ['ie >= 11'],
additionalLegacyPolyfills: ['regenerator-runtime/runtime']
})
],
resolve: {
alias: {
'@': path.resolve(__dirname, '/src'),
'~bootstrap': 'bootstrap'
}
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@import "./src/scss/variables";`
}
}
}
}
我的文件夹结构:
我的软件包. json
{
"name": "co",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"devDependencies": {
"@fullhuman/postcss-purgecss": "^4.1.3",
"@vitejs/plugin-legacy": "^1.8.1",
"@vitejs/plugin-vue": "^1.6.1",
"autoprefixer": "^10.4.5",
"postcss": "^8.4.12",
"sass": "~1.32.13",
"vite": "^2.9.6",
"vite-plugin-vue2": "^1.9.0",
"vue-template-compiler": "^2.6.11"
},
"dependencies": {
"bootstrap": "^4.6.0",
"eslint": "^8.14.0",
"eslint-plugin-vue": "^8.7.1",
"vue": "^2.6.11",
"vue-router": "^3.2.0"
}
}
2条答案
按热度按时间5f0d552i1#
更新了我的配置如下。似乎已经得到它的工作!
p5cysglq2#
这个对我也有用
我在
package.json
文件旁边创建了一个名为vite.config.js
的文件。并在其中添加了以下代码:
希望这对你有用。