如何解决如何将标准的webpack配置正确调整为webpack-chain
我正在处理将标准webpack配置调整到wepack-chain中,我想将其放入VuePress中的chainWebpack方法中。我的webpack.config.js文件如下所示:
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-chain版本(无效)如下:
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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。