小编Ehs*_*san的帖子

(插件commonjs)SyntaxError:使用rollup打包vue组件时出现意外标记

用rollup打包Vue组件时,出现这样的错误:

(插件 commonjs)语法错误:意外的标记 在此输入图像描述

rollup.config.js:

import peerDepsExternal from "rollup-plugin-peer-deps-external";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "rollup-plugin-typescript2";
import vue from "rollup-plugin-vue";
import {babel} from '@rollup/plugin-babel';

import packageJson from "./package.json";

export default {
    input: "src/index.ts",
    output: [
        {
            format: "cjs",
            file: packageJson.main,
            sourcemap: true
        },
        {
            format: "esm",
            file: packageJson.module,
            sourcemap: true
        }
    ],
    plugins: [babel(), peerDepsExternal(), resolve(), commonjs(), typescript(), vue()]
};
Run Code Online (Sandbox Code Playgroud)

按钮.vue:

<template>
  <button>button</button>
</template>
<script lang="ts">
</script>
Run Code Online (Sandbox Code Playgroud)

有什么解决办法吗?

所以我找到了更好的方法:

最好使用vue-sfc-rollup来打包 Vue 组件。

2023年更新: 现在Vite很流行,你可以使用Vite …

javascript typescript vue.js babeljs rollupjs

6
推荐指数
1
解决办法
6925
查看次数

如何在 vue3 应用程序(vscode)中配置 Stylelint 以在保存时进行 lint

我想在 .vue 组件中检查我的 scss 文件和 scss 范围。我在 stylelint.config 中的配置:

module.exports = {
  extends: [
    'stylelint-config-standard',
    'stylelint-config-recess-order',
    'stylelint-config-prettier',
    'stylelint-config-css-modules',
  ],
  plugins: [
    'stylelint-scss',
  ],
  rules: {},
}
Run Code Online (Sandbox Code Playgroud)

和 package.json:

{
  "scripts": {
    "lint:all:stylelint": "yarn lint:stylelint \"src/**/*.{vue,scss}\""
  },
  "devDependencies": {
    "stylelint": "^14.1.0",
    "stylelint-config-prettier": "^9.0.3",
    "stylelint-config-recess-order": "^3.0.0",
    "stylelint-config-standard": "^24.0.0",
    "stylelint-scss": "^4.0.0",
  }
}
Run Code Online (Sandbox Code Playgroud)

但它不起作用。有什么解决办法吗?

javascript vue.js stylelint vuejs3

3
推荐指数
1
解决办法
4175
查看次数

标签 统计

javascript ×2

vue.js ×2

babeljs ×1

rollupjs ×1

stylelint ×1

typescript ×1

vuejs3 ×1