zoukankan      html  css  js  c++  java
  • 2020-03-22

    庚子鼠年 己卯月 甲子日

    描述

    vue开发

    随笔

    vue练习

    //安装vux
    npm install vux --save
    
    //vux是基于vux-loader的,所以必须要安装这个,否则会报一大堆错
    npm install vux-loader --save-dev
    
    const vuxLoader = require('vux-loader')
    const webpackConfig = originalConfig;
    var originalConfig = vuxLoader.merge(webpackConfig, {
      plugins: ['vux-ui']
    })
    
    

    报错解决

    Module parse failed: Unexpected token (18:6)
    You may need an appropriate loader to handle this file type.
    |     this.$parent.set(this.chartName, {
    |       shape: defaultShapeMap[this.chartName] || '',
    |       ...this.$props,
    |       ...camelAttrs(this.$attrs)
    |     })
    
    
    
    const vuxLoader = require('vux-loader')
    const webpackConfig = originalConfig // 原来的 module.exports 代码赋值给变量 webpackConfig
    
    module.exports = vuxLoader.merge(webpackConfig, {
      plugins: ['vux-ui']
    })
    
    'use strict'
    const path = require('path')
    const utils = require('./utils')
    const config = require('../config')
    const vueLoaderConfig = require('./vue-loader.conf')
    
    function resolve (dir) {
      return path.join(__dirname, '..', dir)
    }
    
    var originalConfig = {
      context: path.resolve(__dirname, '../'),
      entry: {
        app: './src/main.js'
      },
      output: {
        path: config.build.assetsRoot,
        filename: '[name].js',
        publicPath: process.env.NODE_ENV === 'production'
          ? config.build.assetsPublicPath
          : config.dev.assetsPublicPath
      },
      resolve: {
        extensions: ['.js', '.vue', '.json'],
        alias: {
          'vue$': 'vue/dist/vue.esm.js',
          '@': resolve('src'),
        }
      },
      module: {
        rules: [
          {
            test: /.vue$/,
            loader: 'vue-loader',
            options: vueLoaderConfig
          },
          {
            test: /.js$/,
            loader: 'babel-loader',
            include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
          },
          {
            test: /.(png|jpe?g|gif|svg)(?.*)?$/,
            loader: 'url-loader',
            options: {
              limit: 10000,
              name: utils.assetsPath('img/[name].[hash:7].[ext]')
            }
          },
          {
            test: /.(mp4|webm|ogg|mp3|wav|flac|aac)(?.*)?$/,
            loader: 'url-loader',
            options: {
              limit: 10000,
              name: utils.assetsPath('media/[name].[hash:7].[ext]')
            }
          },
          {
            test: /.(woff2?|eot|ttf|otf)(?.*)?$/,
            loader: 'url-loader',
            options: {
              limit: 10000,
              name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
            }
          }
        ]
      },
      node: {
        // prevent webpack from injecting useless setImmediate polyfill because Vue
        // source contains it (although only uses it if it's native).
        setImmediate: false,
        // prevent webpack from injecting mocks to Node native modules
        // that does not make sense for the client
        dgram: 'empty',
        fs: 'empty',
        net: 'empty',
        tls: 'empty',
        child_process: 'empty'
      }
    }
    
    // 配置vux2
    const vuxLoader = require('vux-loader')
    const webpackConfig = originalConfig // 原来的 module.exports 代码赋值给变量 webpackConfig
    
    module.exports = vuxLoader.merge(webpackConfig, {
      plugins: ['vux-ui']
    })
    
    
  • 相关阅读:
    详解log4j2(下)
    linux编译相关知识
    vi/vim正则表达式
    红黑树学习
    转行做程序员之前必须考虑的三件事
    工作十年,你为什么依然没有成为专家
    __sync_fetch_and_add
    STL容器的本质
    学习hash_map从而了解如何写stl里面的hash函数和equal或者compare函数
    c++ union学习
  • 原文地址:https://www.cnblogs.com/chang1024/p/12548875.html
Copyright © 2011-2022 走看看