rollupjs - 构建带有汇总的 Vue.js 3(测试版)应用程序时出现问题:“错误:意外的令牌(请注意,您需要插件才能导入不是 JavaScript 的文件)”
问题描述
我正在尝试使用 Rollup 构建一个 Vue.js 3 (beta) 应用程序。
- Vue.js 3.0.0-beta.15
- 汇总 2.18.1
rollup-plugin-vue
6.0.0-beta.6
我明白了:
$ npx rollup -c rollup.config.prod.js
src/main.js → public/dist/...
[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
src/App.vue?vue&type=style&index=0&id=7ba5bd90&scoped=true&lang.css (2:0)
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
at error (/Users/asko/Git/GroundLevel-es6-firebase-web/node_modules/rollup/dist/shared/rollup.js:5154:30)
at Module.error (/Users/asko/Git/GroundLevel-es6-firebase-web/node_modules/rollup/dist/shared/rollup.js:9592:16)
at tryParse (/Users/asko/Git/GroundLevel-es6-firebase-web/node_modules/rollup/dist/shared/rollup.js:9506:23)
at Module.setSource (/Users/asko/Git/GroundLevel-es6-firebase-web/node_modules/rollup/dist/shared/rollup.js:9890:30)
at ModuleLoader.addModuleSource (/Users/asko/Git/GroundLevel-es6-firebase-web/node_modules/rollup/dist/shared/rollup.js:17749:20)
at ModuleLoader.fetchModule (/Users/asko/Git/GroundLevel-es6-firebase-web/node_modules/rollup/dist/shared/rollup.js:17803:9)
at async Promise.all (index 2)
at ModuleLoader.fetchStaticDependencies (/Users/asko/Git/GroundLevel-es6-firebase-web/node_modules/rollup/dist/shared/rollup.js:17827:34)
at async Promise.all (index 0)
at ModuleLoader.fetchModule (/Users/asko/Git/GroundLevel-es6-firebase-web/node_modules/rollup/dist/shared/rollup.js:17804:9)
at async Promise.all (index 3)
at ModuleLoader.fetchStaticDependencies (/Users/asko/Git/GroundLevel-es6-firebase-web/node_modules/rollup/dist/shared/rollup.js:17827:34)
at async Promise.all (index 0)
at ModuleLoader.fetchModule (/Users/asko/Git/GroundLevel-es6-firebase-web/node_modules/rollup/dist/shared/rollup.js:17804:9)
at async Promise.all (index 0)
我的汇总配置:
import resolve from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import fileSize from 'rollup-plugin-filesize';
import vue from 'rollup-plugin-vue';
const plugins = [
resolve(),
vue({
template: {
isProduction: true,
//compilerOptions: { preserveWhitespace: false }
},
//css: false, // note: 'false' extracts styles as a separate '.css' file
}),
replace({ 'process.env.NODE_ENV': '"production"' }),
fileSize()
];
export default {
plugins,
input: 'src/main.js',
output: {
dir: 'public/dist/',
format: 'esm',
globals: {
firebaseui: "firebaseui"
},
sourcemap: true // have source map even for production
}
};
已经苦苦寻找类似的案例,但还没有找到解决方案。有谁知道,这可能是关于什么的?
资料来源:资料来源:https ://github.com/akauppi/GroundLevel-es6-firebase-web/tree/pr-prod
解决方案
推荐阅读
- r - 使用`map`按列名查找rowMeans
- java - 进入使用 Firebase 身份验证和数据库的活动时,我的应用程序崩溃
- swift - 所有 VC 的一个 UI 元素
- bash - 从一个进程中并行读取 n 个管道
- node.js - 未在 node.js 上接收发布数据
- python - Python package is installed but can't be imported
- actions-on-google - Training improvements on new actions builder
- django - 将迁移添加到源代码管理并合并 Django 中的冲突迁移
- vue.js - 使卡片内的列之间的空间变小
- c# - Entity Framework Core - 加载子实体