为了账号安全,请及时绑定邮箱和手机立即绑定

webpack4中使用extract-text-webpack-plugin@4.0.0-beta.0没有生成文件

webpack4中使用extract-text-webpack-plugin@4.0.0-beta.0没有生成文件

jeck猫 2019-05-12 12:09:31
webpack4中使用extract-text-webpack-plugin@4.0.0-beta.0进行样式文件提取却没有生成文件,安装了extract-text-webpack-plugin@4.0.0-beta.0,却发现可以编译成功,却没有css文件生成配置文件如下:constExtractTextPlugin=require("extract-text-webpack-plugin");constconfig={entry:{app:__dirname+'/src/app.js',main:__dirname+'/src/index.js'},output:{filename:'[name]-[hash].js',path:__dirname+'/dist'},mode:'development',devtool:'source-map',//设置sourcemap选项devServer:{//设置webpack本地服务器的配置contentBase:'./dist',//默认webpack-dev-server会为根文件夹提供本地服务器,如果想为另外一个目录下的文件提供本地服务器port:'8383',//监听端口inline:true,//设置为true,当源文件改变的时候会自动刷新historyApiFallback:true,//在开发单页应用时非常有用,它依赖于HTML5historyAPI,如果设置为true,所有的跳转将指向index.htmlhot:true//允许热加载},module:{rules:[{test:/\.css$/,use:[{loader:'style-loader'},{loader:'css-loader',options:{modules:true,//指定cssmoduleslocalIdentName:'[name]__[local]--[hash:base64:5]'//指定css的类名格式}},{loader:'postcss-loader'}]},{test:/\.less$/,use:ExtractTextPlugin.extract({//分离less编译后的css文件fallback:'style-loader',use:['css-loader','less-loader']})},{test:/\.js$/,use:{loader:'babel-loader',options:{presets:['env']}},exclude:/node_modules/},{test:/\.vue$/,use:{loader:'vue-loader'}}]},resolve:{alias:{'vue':'vue/dist/vue.js'}},plugins:[newExtractTextPlugin("css/index.css")]};module.exports=config;在执行webpack命令后却没有对应的index.css生成,这是怎么回事?
查看完整描述

2 回答

?
慕神8447489

TA贡献1780条经验 获得超1个赞

plugins:[
newExtractTextPlugin({
filename:`[name]_[id]_[hash:8].css`,
})
]
配置里面短代码了吧
                            
查看完整回答
反对 回复 2019-05-12
  • 2 回答
  • 0 关注
  • 1350 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号