vue項目使用vux框架配置教程

吐槽下,這個vux配置教程那。。寫的實在是坑,也不搞個示例代碼。。。想上天嗎????vue

正常安裝的話。。。100%報錯。。。如下是正確配置webpack

 1.項目裏安裝vux 
  npm install vux --save 
  2.安裝vux-loader(vux2必須結合vux-loader使用,本文也只是介紹vux2的配置) 
  npm install vux-loader --save-dev 
  3.安裝less-loader 
  npm install less less-loader --save-dev 
  安裝完成記得在webpack.base.conf.js裏作以下配置,在extensions里加入less

web

4.安裝yaml-loader 
  npm install yaml-loader --save-dev 
  最後一步在build/webpack.base.conf.js文件裏將原來的module.exports的代碼賦值給一個新的變量webpackConfig,整個文件以下:

npm

'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vuxLoader = require('vux-loader')
const vueLoaderConfig = require('./vue-loader.conf')

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', 'less'],
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')]
},
{
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]')
}
}
]
}
}

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

 

  而後再重啓下。。。完美運行。。。babel

相關文章
相關標籤/搜索