webpack.config.split.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. var path = require("path");
  2. var webpack = require('webpack');
  3. var BundleTracker = require('webpack-bundle-tracker');
  4. var SplitByPathPlugin = require('webpack-split-by-path');
  5. var ExtractTextPlugin = require("extract-text-webpack-plugin");
  6. module.exports = {
  7. context: __dirname,
  8. entry: './assets/js/index',
  9. output: {
  10. path: path.resolve('./assets/bundles/'),
  11. filename: "[name].js",
  12. chunkFilename: "[name].js"
  13. },
  14. plugins: [
  15. new ExtractTextPlugin("styles.css"),
  16. new BundleTracker({filename: './webpack-stats.json'}),
  17. new SplitByPathPlugin([
  18. {
  19. name: 'vendor',
  20. path: path.join(__dirname, '/node_modules/')
  21. }
  22. ])
  23. ],
  24. module: {
  25. loaders: [
  26. // we pass the output from babel loader to react-hot loader
  27. { test: /\.jsx?$/, exclude: /node_modules/, loaders: ['babel'], },
  28. { test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader") }
  29. ],
  30. },
  31. resolve: {
  32. modulesDirectories: ['node_modules', 'bower_components'],
  33. extensions: ['', '.js', '.jsx']
  34. },
  35. }