TypeError:路径必须是字符串。在执行npm run build之后收到未定义的错误

时间:2019-05-18 06:27:02

标签: node.js path vuejs2 webpack-4 vue-cli-3

我是webpack的新手,想在由vue-cli3创建的vue.config.js文件中使用html-critical-webpack-plugin。但是我在vue.config.js文件中使用const path = require('path')时收到此错误。我的根文件夹中没有任何webpack.config.js文件。如何在vue.config.js文件中使用它?

const path = require('path')
const HtmlCriticalPlugin = require("html-critical-webpack-plugin");
const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin')
module.exports = {
  configureWebpack: {
    optimization: {
      splitChunks: {
        chunks: 'all',
      },
    },
    plugins: [
      new VuetifyLoaderPlugin(),
      new HtmlCriticalPlugin({
        base: path.join(path.resolve(__dirname), 'dist/'),
        src: 'index.html',
        dest: 'index.html',
        inline: true,
        minify: true,
        extract: true,
        width: 375,
        height: 565,
        penthouse: {
          blockJSRequests: false,
        }
      })
    ]
  },
  devServer: {
    disableHostCheck: true,
  },
  lintOnSave: false,
  pwa: {
    // configure the workbox plugin
    workboxPluginMode: 'InjectManifest',
    workboxOptions: {
      // swSrc is required in InjectManifest mode.
      swSrc: 'src/service-worker.js'
    }
  }
}

0 个答案:

没有答案