关于vue-hackernews里的webpack.config.js文件?
发布于 8 年前 作者 QuoniamYIF 3954 次浏览 来自 问答

下面是vue-hackernews里的webpack.config.js文件,想请教一下,为什么要写: exclude: /node_modules|vue\/dist|vue-router\/|vue-loader\/|vue-hot-reload-api\//, 这段代码,直接写成exclude: /node_modules/不就行了嘛?

var webpack = require('webpack')

module.exports = {
  entry: './src/main.js',
  output: {
    path: './static',
    publicPath: '/static/',
    filename: 'build.js'
  },
  module: {
    // avoid webpack trying to shim process
    noParse: /es6-promise\.js$/,
    loaders: [
      {
        test: /\.vue$/,
        loader: 'vue'
      },
      {
        test: /\.js$/,
        // excluding some local linked packages.
        // for normal use cases only node_modules is needed.
        exclude: /node_modules|vue\/dist|vue-router\/|vue-loader\/|vue-hot-reload-api\//,
        loader: 'babel'
      }
    ]
  },
  babel: {
    presets: ['es2015'],
    plugins: ['transform-runtime']
  }
}
3 回复

这叫正则… 你直接写个/node_modules/直接报错啊

意思是除了node_modules,vue/dist,vue-router/,vue-hot-reload-api/以外

@Smallpath@artisan 我想问的是为什么要除了node_modules,vue/dist,vue-router/,vue-hot-reload-api/这些以外

回到顶部