Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. var HtmlWebpackPlugin = require( 'html-webpack-plugin' );
  2. var ExtractTextPlugin = require( 'extract-text-webpack-plugin' );
  3. var path = require( 'path' );
  4.  
  5. module.exports = {
  6. devServer: {
  7. compress: true,
  8. contentBase: path.join( __dirname, '/dist' ),
  9. open: true,
  10. port: 9000,
  11. stats: 'errors-only'
  12. },
  13. entry: './src/app.js',
  14. output: {
  15. path: path.join( __dirname, '/dist' ),
  16. filename: 'app.bundle.js'
  17. },
  18. module: {
  19. rules: [ {
  20. test: /.scss$/,
  21. use: ExtractTextPlugin.extract( {
  22. fallback: 'style-loader',
  23. use: [
  24. 'css-loader',
  25. 'sass-loader'
  26. ],
  27. publicPath: '/dist'
  28. } )
  29. } ]
  30. },
  31. plugins: [
  32. new HtmlWebpackPlugin( {
  33. hash: true,
  34. minify: { collapseWhitespace: true },
  35. template: './src/index.html',
  36. title: 'Prov'
  37. } ),
  38. new ExtractTextPlugin( {
  39. filename: 'main.css',
  40. allChunks: true
  41. } )
  42. ]
  43. };
  44.  
  45. var angular = require('angular');
  46. var proverbList = require('./proverb/list/proverb.list');
  47. // require other components
  48.  
  49. // set up your app as normal
  50.  
  51. const globby = require('globby');
  52. const sourceDir = 'src';
  53. var webpackentry = {
  54. app: `${__dirname}/src/app.js`
  55. };
  56.  
  57. const glob = globby.sync(`${__dirname}/${sourceDir}/**/*.js`)
  58. .map((file)=>{
  59. let name = file.split('/').pop().replace('.js', '');
  60. webpackentry[name] = file;
  61. });
  62.  
  63.  
  64. const config = {
  65. entry: webpackentry,
  66. ...
  67. }
  68.  
  69. let webpackentry = {
  70. vendor: [
  71. 'module1',
  72. 'module2',
  73. 'module3',
  74. ]
  75. }
  76. ...
  77. plugins: [
  78. new webpack.optimize.CommonsChunkPlugin({
  79. name: ['vendor', 'manifest'] //... add other modules
  80. })
  81. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement