问答详情
源自:2-1 vue-loader+webpack项目配置

ERROR in ./src/index.js 1:16 Module parse failed: Unexpected token (1:16)

ERROR in ./src/index.js 1:16

Module parse failed: Unexpected token (1:16)

You may need an appropriate loader to handle this file type.

> import Vue from vue;

| import App from './app.vue';

|


提问者:慕的地2499907 2018-09-11 15:54

个回答

  • fallen_down
    2018-09-14 11:24:07

    我找到了答案,分享给大家。

    只要修改webpack.config.js就可以打包了。

    const path = require('path');   

    const {VueLoaderPlugin}=require('vue-loader');  


        module.exports = {

            entry: path.resolve(__dirname, "src/index.js"),   //webpack4官方绝对路径

        devServer: {

            contentBase: './dist'

        },

        output: {

        filename: 'bundle.js',

            path: path.resolve(__dirname, 'dist')

        },

        module: {

        rules: [

            {

    test: /\.vue$/,

    use: [

    'vue-loader'        

    ]

    },

    {

    test: /\.css$/,

    use: [

    'vue-style-loader',                //可以不要

    'style-loader',                        

    'css-loader'

    ]

    },

    ]

    },

    plugins:[

    new VueLoaderPlugin()

    ]

    };


  • 慕的地2499907
    2018-09-11 16:38:33

    https://img.mukewang.com/5b977efa0001ba6604750118.jpg

    谁能帮忙看下啊