yangtongjie
2017-05-10 22:46
var path = require('path'); var htmWebpackPlugin = require('html-webpack-plugin'); var webpack = require('webpack'); module.exports={ context: __dirname, entry: './src/app.js', output:{ path: path.resolve(__dirname,'dist'), filename: 'js/[name].bundle.js' }, module: { loaders: [ { test: /\.js$/, loader: 'babel-loader', exclude: __dirname+'./node_modules', include: __dirname+'./src/', options: { 'presets': ['latest'] } }, { test: /\.css$/, use: [ { loader: 'style-loader' }, { loader: 'css-loader', options: { importLoaders:1 } }, { loader: 'postcss-loader' } ] } ] }, plugins: [ new htmWebpackPlugin({ filename: 'index.html', template: 'index.html', inject: 'body' }), new webpack.LoaderOptionsPlugin({ options: { postcss: function(){ return [ require('autoprefixer')({ broswers: ['last 5 versions'] }) ] } } }) ] }
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: path.resolve(__dirname,
'node_modules'),
include: path.resolve(__dirname,
'src'),
/*还可以在package.json里面配置*/query: {
presets: [
'latest'
]
}
},
{
test: /\.css$/,
//loader: 'style-loader!css-loader!postcss-loader'loaders: [
{
loader: 'style-loader'
},
{
loader: 'css-loader',
options: {
importLoaders: 1
}
},
{
loader: "postcss-loader",
options: {
plugins: ()=>[
require('autoprefixer')({
broswers: [
'last5versions'
]
}),
require('postcss-import')()
]
},
}
]
}
]
}
我也跟你一样配置的,也是错误。别的都成了,不知道为什么。很郁闷。最后弄了个postcss.config.js里面配置:
module.exports = { plugins:[ require('autoprefixer')({ browsers: ["last 5 versions"]}) ] }
才行了。不知道你现在搞定了没?怎么配置的?
webpack深入与实战
86561 学习 · 721 问题
相似问题