码迷,mamicode.com
首页 > 其他好文 > 详细

2020-03-22

时间:2020-03-22 22:30:50      阅读:96      评论:0      收藏:0      [点我收藏+]

标签:ati   ons   必须   ops   contex   default   name   fill   filename   

庚子鼠年 己卯月 甲子日

描述

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‘]
})

2020-03-22

标签:ati   ons   必须   ops   contex   default   name   fill   filename   

原文地址:https://www.cnblogs.com/chang1024/p/12548875.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!