账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    webpack怎样使用happypack的
    53
    0

    在vue-cli构建的项目里的想使用happypack这个插件加快项目的构建的 但是不知道怎么用 看了下github上的介绍 还是不太明白 上面写的在webpack.config.js配置如果下代码
    var HappyPack = require('happypack');

    exports.plugins = [
    new HappyPack({

    // loaders is the only required parameter:
    loaders: [ 'babel?presets[]=es2015' ],
    
    // customize as needed, see Configuration below

    })
    ];

    exports.module = {
    loaders: {

    test: /.js$/,
    loaders: [ 'happypack/loader' ],
    include: [
      // ...
    ],

    }
    };

    但是现在webpack里没有webpack.config.js文件呀 这应该是在webpack.base.conf.js里配置不是在webpack.prod.conf.js或者webpack.dev.conf.js里配置呢
    现在webpack.base.conf.js代码是这样的
    '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)
    }

    module.exports = {
    context: path.resolve(__dirname, '../'),
    entry: ["babel-polyfill", "./src/main.js"],
    /*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'),
      'components': path.resolve(__dirname,'../src/components'),
      'assets': path.resolve(__dirname,'../src/assets'),
      'js': path.resolve(__dirname,'../src/js'),
      'api': path.resolve(__dirname, '../src/api'),
      'service': path.resolve(__dirname, '../src/service'),
      'tools': path.resolve(__dirname, '../src/tools'),
      'jquery': path.resolve(__dirname, '../node_modules/jquery/src/jquery')
    }

    },
    module: {

    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: vueLoaderConfig,
        exclude: /node_modules\/(?!(autotrack|dom-utils))|vendor\.dll\.js/
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        include: [resolve('src'), resolve('test'), resolve('node_modules/_iview@2.7.3@iview/'), resolve('node_modules/_vue-confirm@1.1.1@vue-confirm')]
      },
      {
        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]')
        }
      }
    ]

    }
    }

    1
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 快来拉我 普通会员 1楼
      502 Bad Gateway

      502 Bad Gateway


      nginx
    更多回答
    网站公告
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部