我正在Vue.js中使用PostCSS。
我正在尝试通过npm Bulma,Vuedicity,Vue-sweetalert2 ...进行安装
并且总是相同的响应。
Failed to compile.
./node_modules/vue-sweetalert2/src/index.js
Module not found: Error: Can't resolve 'postcss-loader' in
'/home/miguel/Documents/trabajos/desarrollo/hegeo/frontend'
@ ./node_modules/vue-sweetalert2/src/index.js 4:0-46
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://localhost:8080
webpack/hot/dev-server ./src/main.js
我通过CDN安装了它们,并且可以正常工作。
这是我的webpack配置:
var path = require('path')
var webpack = require('webpack')
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
filename: 'build.js'
},
module: {
rules: [
{
test: /\.css$/,
use: [
'vue-style-loader',
{ loader: 'css-loader', options: { importLoaders: 1 } },
'postcss-loader',
],
}, {
test: /\.vue$/,
loader: 'vue-loader',
options: {
postcss: [require('postcss-cssnext')()],
loaders: {
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]