1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| var webpack = require('webpack'); module.export = { entry: _dirname + "/app/index.js", // 入口文件 output: { path: _dirname + "/public", //输出文件路径 filename: "bundle.js" //输出文件名 }, module: { loaders:[ //加载器list { test: /\.js$/, excule: /node_modules/, loader: 'babel', query: { presets: [ 'es2015', 'react' ] } }, { test: /\.scss$/, loader: 'style!css!postcss!sass' }, { test: /\.css$/, loader: ExtractTextPlugin.extract('css') } ], postcss: function () { return [autoprefixer] }, plugins: [ new webpack.optimize.UglifyJsPlugin(), //压缩代码 new webpack.DefinedPlugin({ 'process.env.NODE_ENV' : 'production' // 见注1 }), new WebpackMd5Hash(), new ExtractTextPlugin("bundle-[contenthash].css") // 根据hash值进行缓存控制静态资源css文件 ] }, devServer: { //web server 配置 contentBase: "./public", inline: true } }
|