'use strict';
var ExtractTextPlugin = require("extract-text-webpack-plugin"); //css单独打包
var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
module.exports={
entry:'./app.js',//唯一入口文件
output: {
path:__dirname+ "/dist",//打包后文件存放的位置,
filename: "main.js",//打包后输出文件的文件名
publicPath: 'http://localhost:9999/dist/' //启动本地服务后的根目录
},
module:{
loaders: [
{ test: /\.js$/, loader: "babel-loader", exclude: /^node_modules$/,query:{
presets: ['es2015', 'react', 'stage-2'],
}},
{ test: /\.css$/, loader:'css-loader!autoprefixer-loader'},
{ test: /\.scss$/, loader: 'style-loader!css-loader!sass-loader'},
{ test: /\.(png|jpg|gif)$/, loader: 'url?limit=819200'}
]
},
devServer: {
contentBase: './dist', //本地服务器所加载的页面所在的目录
port: 9999,
// colors: true, //终端中输出结果为彩色
historyApiFallback: true, //不跳转
inline: true //实时刷新
},
plugins: [
new ExtractTextPlugin('css[name].css'),
]
};