• webpack入门四 安装vue,并打包


    //vue开发------------------------------------------------------------------------
    npm install vue

    webpack.config.js
    const HtmlWebpackPlugin = require('html-webpack-plugin');
    const CopyPlugin = require("copy-webpack-plugin");
    const {CleanWebpackPlugin} = require("clean-webpack-plugin");
    var path = require('path');
    module.exports = {
        entry: './src/main.js',
        output: {path: path.resolve(__dirname, './dist'), filename: 'app.js'},
        module: {
            rules: [
                {
                    test: /.css$/i,
                    use: ['style-loader', 'css-loader']
                },
                {
                    test: /.(png|jpg|gif)$/i,
                    use: [
                        {
                            loader: 'url-loader',
                            options:
                                {
                                    limit: 8192,
                                    name: '[path][name].[ext]',
                                },
                        },
                    ],
                },
                {
                    test: /.vue$/i,
                    use: ['vue-loader']
                },
    
            ],
        },
        plugins: [
            new CleanWebpackPlugin(),
            new HtmlWebpackPlugin({
                title: 'Custom template',
                // filename:'index.html',
                inject: 'body',
                template: path.resolve(__dirname, "index.html")
            }),
            new CopyPlugin({
                patterns: [
                    {from: "static", to: "static"},
                ],
            }),
        ],
        resolve: {
            alias:
                {
                    'vue': 'vue/dist/vue.js'
                }
        }
    };

    main.js

    import user from './t1'
    import css from './t1.css'
    import Vue from 'vue'
    
    console.log('this is main', user, css, Vue)
    var main = new Vue({
        el: '#app',
        data: {
            message: 'Hello Vue!'
        },
    })

    index.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
    <div id="app">
        <h3>{{message}}</h3>
    </div>
    </body>
    </html>

    天生我材必有用,千金散尽还复来
  • 相关阅读:
    DOS命令收集
    iis6配置支持.net4.0
    正则表达式限制文本框
    剖析XML(第一讲)
    DataTime.ToString("xx") 转换
    .net面试题大汇集
    django学习笔记(一)
    django学习笔记(一)
    django学习笔记(二)
    django学习笔记(二)
  • 原文地址:https://www.cnblogs.com/ligenyun/p/14385684.html
Copyright © 2020-2023  润新知