css文件的 处理有问题

来源:5-3 服务端渲染的entry配置

旋涡鸣人_

2018-10-24

{
test: /.styl/,
use: [
MiniCssExtractPlugin.loader,
‘css-loader’,
{
loader: ‘postcss-loader’,
options: {
sourceMap: true
}
},
‘stylus-loader’
]
}

然后运行

npm run dev:server

server is listening on 0.0.0.0
./client/app.vue?vue&type=style&index=0&id=7752612a&lang=stylus&scoped=true& (./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref–5-2!./node_modules/stylus-loader!./node_modules/vue-loader/lib??vue-loader-options!./client/app.vue?vue&type=style&index=0&id=7752612a&lang=stylus&scoped=true&)
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
TypeError: this[NS] is not a function
at childCompiler.runAsChild (/Users/achilles/yilong/todo/node_modules/mini-css-extract-plugin/dist/loader.js:148:15)

后来又修改为:

plugins: defaultPluins.concat([
new webpack.DefinePlugin({
“process.env.NODE_ENV”: JSON.stringify(JSON.stringify(process.env.NODE_ENV || ‘development’)),
“process.env.VUE_ENV”: ‘“server”’
}),
new VueServerPlugin(),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: ‘[name].[hash].css’,
chunkFilename: ‘[id].[hash].css’
})
//new webpack.HotModuleReplacementPlugin()
// new webpack.NoEmitOnErrorsPlugin()
])
也还是没又样式。。。

写回答

1回答

Jokcy

2018-10-24

https://github.com/webpack-contrib/mini-css-extract-plugin/issues/73#issuecomment-380510188

0
4
Jokcy
回复
旋涡鸣人_
简单说就是再开发环境下不要用这个插件,在正式环境打包的时候再用
2018-10-29
共4条回复

Vue核心技术 Vue+Vue-Router+Vuex+SSR实战精讲

深入讲解Vue核心技术,展示Vue应用开发中的各种问题和解决方案

3168 学习 · 853 问题

查看课程