Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. global.Promise = require('bluebird');
  2.  
  3. var webpack = require('webpack');
  4. var path = require('path');
  5. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  6. const { CleanWebpackPlugin } = require('clean-webpack-plugin');
  7.  
  8. var publicPath = 'http://localhost:8050/public/assets';
  9. var cssName = process.env.NODE_ENV === 'production' ? 'styles-[hash].css' : 'styles.css';
  10. var jsName = process.env.NODE_ENV === 'production' ? 'bundle-[hash].js' : 'bundle.js';
  11.  
  12. var plugins = [
  13. new webpack.DefinePlugin({
  14. 'process.env': {
  15. BROWSER: JSON.stringify(true),
  16. NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
  17. }
  18. }),
  19. new MiniCssExtractPlugin({
  20. // Options similar to the same options in webpackOptions.output
  21. // all options are optional
  22. filename: cssName,
  23. chunkFilename: '[id].css',
  24. ignoreOrder: false, // Enable to remove warnings about conflicting order
  25. }),
  26. new webpack.LoaderOptionsPlugin({
  27. options: {
  28. eslint: {
  29. configFile: '.eslintrc'
  30. }
  31. }
  32. })
  33. ];
  34.  
  35. if (process.env.NODE_ENV === 'production') {
  36. plugins.push(
  37. new CleanWebpackPlugin({
  38. verbose: true,
  39. dry: false
  40. })
  41. );
  42. plugins.push(new webpack.optimize.OccurrenceOrderPlugin());
  43. }
  44.  
  45. module.exports = {
  46. entry: ['babel-polyfill', './src/client.js'],
  47. //debug: process.env.NODE_ENV !== 'production',
  48. resolve: {
  49. modules: [__dirname, 'node_modules'],
  50. extensions: ['*', '.js', '.jsx']
  51. },
  52. plugins,
  53. output: {
  54. path: `${__dirname}/public/assets/`,
  55. filename: jsName,
  56. publicPath
  57. },
  58. module: {
  59. rules: [
  60. {
  61. test: /\.css$/,
  62. use: [
  63. {
  64. loader: MiniCssExtractPlugin.loader,
  65. options: {
  66. // you can specify a publicPath here
  67. // by default it uses publicPath in webpackOptions.output
  68. publicPath: '../',
  69. hmr: process.env.NODE_ENV === 'development',
  70. },
  71. },
  72. 'css-loader',
  73. ],
  74. },
  75. /*{
  76. test: /\.less$/,
  77. loader: MiniCssExtractPlugin.extract('style-loader', 'css-loader!postcss-loader!less-loader')
  78. },*/
  79. { test: /\.gif$/, loader: 'url-loader?limit=10000&mimetype=image/gif' },
  80. { test: /\.jpg$/, loader: 'url-loader?limit=10000&mimetype=image/jpg' },
  81. { test: /\.png$/, loader: 'url-loader?limit=10000&mimetype=image/png' },
  82. { test: /\.svg/, loader: 'url-loader?limit=26000&mimetype=image/svg+xml' },
  83. { test: /\.(woff|woff2|ttf|eot)/, loader: 'url-loader?limit=1' },
  84. { test: /\.jsx?$/, loader: process.env.NODE_ENV !== 'production' ? 'babel-loader!eslint-loader' : 'babel-loader', exclude: [/node_modules/, /public/] },
  85. { test: /\.json$/, loader: 'json-loader' },
  86. ]
  87. },
  88. //devtool: process.env.NODE_ENV !== 'production' ? 'source-map' : null,
  89. devServer: {
  90. headers: { 'Access-Control-Allow-Origin': '*' }
  91. },
  92. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement