vux环境配置

Posted chenziyu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vux环境配置相关的知识,希望对你有一定的参考价值。

1.安装VUX依赖

npm install vux --save

2.安装vux-loader

npm install vux-loader --save-dev

3.安装less-loader

npm install less less-loader --save-dev

4.

在bulid —>webpack.base.conf.js下,

1)首先引入vux-loader

const vuxLoader = require(‘vux-loader‘)

5.然后将原来的module.exports 替换成const 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‘)
const vuxLoader = require(‘vux-loader‘)

function resolve (dir) {
  return path.join(__dirname, ‘..‘, dir)
}

const webpackConfig = {
  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‘
  }
}

module.exports = vuxLoader.merge(webpackConfig, {
  plugins: [‘vux-ui‘]
})

 

以上是关于vux环境配置的主要内容,如果未能解决你的问题,请参考以下文章

《vue里用vux写移动端搭建环境》

移动端vue项目构建配置环境 vue-router路由 VUX ui框架 axios请求等等~~

Vue中的Vux配置指南

vue+vux+es6+webpack移动端常用配置步骤

Vux配置指南

vux 项目的构建