vue使用中的一些小窍门

1.设置src为@,在webpack.base.conf.js中修改resolve中的alias

resolve: {
    extensions: ['.js', '.vue', '.json','.scss'],
    alias: {
      'vue$': 'vue/dist/vue.esm.js',
      '@': resolve('src'),
    }
  },

2.设置打包图片限制大小,在webpack.base.conf.js中修改resolve中的module中的limit

module: {
    rules: [
    {
        test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
        loader: 'url-loader',
        options: {
          limit: 10000,
          name: utils.assetsPath('img/[name].[hash:7].[ext]')
        }
      },
    ]}

3.修改生产环境去掉console和debugger,在webpack.prod.conf.js中修改如下

new UglifyJsPlugin({
      uglifyOptions: {
        compress: {
          warnings: false,
          drop_debugger: true,
          drop_console: true//去除console.log和debugger
        }
      },
      sourceMap: config.build.productionSourceMap,
      parallel: true
    }),

你可能感兴趣的:(vue.js,es6,javascript)