Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Failed to integrate babel with vue: Unexpected token <template> #231

Closed
ahuigo opened this issue Sep 3, 2018 · 2 comments
Closed

Failed to integrate babel with vue: Unexpected token <template> #231

ahuigo opened this issue Sep 3, 2018 · 2 comments

Comments

@ahuigo
Copy link

ahuigo commented Sep 3, 2018

Expected behavior

Successfully integrate babel

Actual behavior

Failed to integrate babel

Steps to reproduce the behavior

$ git clone https://coding.net/u/hilojack/p/my-rollup-issue/git vue2
$ cd vue2
$  npm i
$ rollup -c -w
[!] (babel plugin) SyntaxError: /Users/hilojack/www/egg/vue2/src/App.vue: Unexpected token (1:0)
src/App.vue (1:0)
SyntaxError: /Users/hilojack/www/egg/vue2/src/App.vue: Unexpected token (1:0)
> 1 | <template>
    | ^
  2 |     <div class="container">
 

rollup.config.js

import json from "rollup-plugin-json";
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import babel from "rollup-plugin-babel";
import VuePlugin from "rollup-plugin-vue";

import replace from 'rollup-plugin-replace';

import uglify from 'rollup-plugin-uglify';
//import postcss from 'rollup-plugin-postcss';

export default{
    //input: "src/main.js",
    input: ["src/index.js"],
	output: {
        format: "esm",
        name: "myBundle",
        dir: "dist",
        //file: "dist/bundle.js",
        paths: {
            vue: "https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.esm.browser.js",
        }
	},
    experimentalCodeSplitting: true,
    external: ["lodash", "vue"],
    watch: {
        //exclude: ['node_modules/**', 'dist/**',], //default  ignore
        include: ['src/**','src/App.vue'],
    },
    plugins:[
        babel({ exclude: 'node_modules/**' }),
        json(),
        //resolve({ jsnext: true, main: true, browser: true, }),
        resolve({ browser: true, }),
        commonjs(),
        VuePlugin(),
        replace({
          exclude: 'node_modules/**',
          ENV: JSON.stringify(process.env.NODE_ENV || 'development'),
        }),
        (process.env.NODE_ENV === 'production' && uglify()),
    ],
};
@ahuigo ahuigo changed the title Failed to integrate babel Failed to integrate babel with vue: Unexpected token <template> Sep 3, 2018
@znck
Copy link
Member

znck commented Oct 28, 2018

Plugin order matters here, putting VuePlugin() at the start of the list would help.

@znck
Copy link
Member

znck commented Jan 14, 2019

Add babel({ exclude: 'node_modules/**', include: '**/*.js' }).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants