You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

webpack.config.js 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. var path = require('path');
  2. var ExtractTextPlugin = require('extract-text-webpack-plugin');
  3. var webpack = require('webpack');
  4. var AssetsPlugin = require('assets-webpack-plugin');
  5. module.exports = {
  6. entry: {
  7. app: './js/main.js'
  8. },
  9. module: {
  10. rules: [
  11. {
  12. test: /\.js$/,
  13. exclude: /node_modules/,
  14. use: {
  15. loader: 'babel-loader',
  16. options: {
  17. presets: ['env']
  18. }
  19. }
  20. },
  21. {
  22. test: /\.css$/,
  23. use: ExtractTextPlugin.extract({
  24. fallback: 'style-loader',
  25. use: 'css-loader?importLoaders=1!postcss-loader'
  26. })
  27. }
  28. ]
  29. },
  30. output: {
  31. path: path.join(__dirname, './../static/dist'),
  32. filename: 'js/[name].[chunkhash].js'
  33. },
  34. resolve: {
  35. modules: [path.resolve(__dirname, 'src'), 'node_modules']
  36. },
  37. plugins: [
  38. new AssetsPlugin({
  39. filename: 'webpack_assets.json',
  40. path: path.join(__dirname, '../data'),
  41. prettyPrint: true
  42. }),
  43. new ExtractTextPlugin({
  44. filename: getPath => {
  45. return getPath('css/[name].[contenthash].css');
  46. },
  47. allChunks: true
  48. })
  49. ],
  50. watchOptions: {
  51. watch: true
  52. }
  53. };