我是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'
}
}
}