Vue.js 如何将标准的网页配置调整为网页包链
我正在处理将标准webpack配置调整为wepack链的问题,我希望将其放入VuePress中的chainWebpack方法中。我的webpack.config.js文件如下所示:Vue.js 如何将标准的网页配置调整为网页包链,vue.js,webpack,vuepress,Vue.js,Webpack,Vuepress,我正在处理将标准webpack配置调整为wepack链的问题,我希望将其放入VuePress中的chainWebpack方法中。我的webpack.config.js文件如下所示: const path = require('path'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const MODE = "development"; module.exports = { entr
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const MODE = "development";
module.exports = {
entry: './docs/scss/index.js',
mode: MODE,
watch: true,
output: {
path: path.resolve(__dirname, './docs/.vuepress/public'),
},
plugins: [
new MiniCssExtractPlugin({
filename: 'style.css',
}),
],
module: {
rules: [
{
test: /\.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
{ loader: 'css-loader', options: { url: false, sourceMap: true } },
{ loader: 'sass-loader', options: { sourceMap: true } },
]
},
],
},
};
我的weback链的当前版本(不起作用)如下所示:
chainWebpack (config, isServer) {
if (!isServer) {
config
.entry('index')
.add(path.resolve(process.cwd(), './docs/.vuepress/index.js'))
.end()
config.plugin('css').use(MiniCssExtractPlugin, [{
filename: '[name].css',
chunkFilename: '[id].css',
}])
config.module.rule('css-module')
.test(/\.(sa|sc|c)ss$/)
.use('mini-css')
.loader(MiniCssExtractPlugin.loader)
.end()
.oneOf('normal')
.use('css-loader')
.loader('css-loader')
.options({
url: false,
sourceMap: true,
})
.end()
.oneOf('sass')
.use('sass-loader')
.loader('sass-loader')
.options({
sourceMap: true,
})
.end()
}
执行上述代码后的错误消息:
(1:1) Unknown word > 1 | // extracted by mini-css-extract-plugin
Npx vuepress信息提供该输出:
Environment Info:
System:
OS: Windows 10 10.0.18363
Binaries:
Node: 14.4.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.14.5 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 85.0.4183.102
Edge: Not Found
npmPackages:
@vuepress/core: 1.5.3
@vuepress/theme-default: 1.5.3
vuepress: ^1.5.3 => 1.5.3
npmGlobalPackages:
vuepress: Not Found