webpack. mini-css-extract-plugin ivew样式失败
// 修改 webppack 配置文件后需重启才能生效
const path = require('path');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const CopyPlugin = require('copy-webpack-plugin')
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
entry: {
main: './src/main',
vendors: './src/vendors'
},
output: {
path: path.join(__dirname, '../dist/assets'), // 输出文件所在目录
},
module: {
rules: [
{
test: /.vue$/,
use: [
{
loader: 'vue-loader'
},
{
loader: 'iview-loader',
options: {
prefix: false
}
}
]
},
{
test: /.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPaht: '../'
}
},
'style-loader', // 为 css 创建 style 标签并置入其中插入页面
'css-loader', // 处理 css
'postcss-loader', // 浏览器兼容问题
],
include:[
/src/,
'/node_modules/view-design/dist/styles/iview.css'
]
},
{
test: /.less$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPaht: '../'
}
},
'style-loader',
'css-loader',
'postcss-loader',
'less-loader' // loader 由下往上依次开始处理
]
},
{
test: /.js$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['env']
}
}
]
},
// 管理字体文件
{
test: /.(woff|woff2|eot|ttf|otf)$/,
use: [
{
loader: 'file-loader',
options: {
name: 'img/[name].[hash:8].[ext]'
}
}
]
},
{
test: /.(gif|jpg|png|woff|svg|eot|ttf)??.*$/,
loader: 'url-loader?limit=1024'
},
{
test: /.(html|tpl)$/,
loader: 'html-loader'
},
{
test: require.resolve('numbro'),
loader: 'expose-loader?numbro'
},
{
test: require.resolve('moment'),
loader: 'expose-loader?moment'
},
{
test: require.resolve('pikaday'),
loader: 'expose-loader?Pikaday'
},
{
test: require.resolve('zeroclipboard'),
loader: 'expose-loader?ZeroClipboard'
}
]
},
resolve: {
extensions: ['.js', '.vue'],
alias: {
'vue': 'vue/dist/vue.esm.js'
}
},
plugins: [
// Vue-loader在15.*之后的版本都是 vue-loader的使用都是需要伴生 VueLoaderPlugin的
new VueLoaderPlugin(),
new CopyPlugin({
patterns: [
{
from: './src/resource',
to: './resource'
}, {
from: './src/images',
to: './images'
}, {
from: './src/api.js',
to: './'
}
],
}),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: "[name].css",
chunkFilename: "[id].css"
})
]
}
在使用MiniCssExtractPlugin之后启动项目就报ivew样式的错,有前辈们遇到过一样的情况吗
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请问,最后是怎么处理的这个问题?