Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. "build": "rm -rf public && npm run build:webpack && npm run build:hugo",
  2. "build:hugo": "hugo -d ../public -s site -v",
  3. "build:webpack": "cross-env NODE_ENV=production webpack --config webpack.prod.js --hot --inline"
  4.  
  5. const webpack = require("webpack");
  6. const path = require("path");
  7. const CopyWebpackPlugin = require("copy-webpack-plugin");
  8. const MiniCssExtractPlugin = require("mini-css-extract-plugin");
  9. const AssetsPlugin = require("assets-webpack-plugin");
  10.  
  11. module.exports = {
  12. entry: {
  13. main: path.join(__dirname, "src", "index.js")
  14. },
  15.  
  16. output: {
  17. path: path.join(__dirname, "public")
  18. },
  19.  
  20. module: {
  21. rules: [
  22. {
  23. test: /.((png)|(eot)|(woff)|(woff2)|(ttf)|(svg)|(gif))(?v=d+.d+.d+)?$/,
  24. loader: "file-loader?name=/[hash].[ext]"
  25. },
  26.  
  27. {test: /.json$/, loader: "json-loader"},
  28.  
  29. {
  30. loader: "babel-loader",
  31. test: /.js?$/,
  32. exclude: /node_modules/,
  33. query: {cacheDirectory: true}
  34. },
  35.  
  36. {
  37. test: /.(sa|sc|c)ss$/,
  38. exclude: /node_modules/,
  39. use: ["style-loader", MiniCssExtractPlugin.loader, "css-loader", "postcss-loader"]
  40. }
  41. ]
  42. },
  43.  
  44. plugins: [
  45. new webpack.ProvidePlugin({
  46. fetch: "imports-loader?this=>global!exports-loader?global.fetch!whatwg-fetch"
  47. }),
  48.  
  49. new CopyWebpackPlugin([
  50. {
  51. from: "./src/fonts/",
  52. to: "fonts/",
  53. flatten: true
  54. }
  55. ]),
  56.  
  57. new CopyWebpackPlugin([
  58. {
  59. from: "./node_modules/@ionic/core/",
  60. to: "ionic/core/",
  61. ignore: ['*.ts', '*.scss', '*e2e.js'],
  62. flatten: false
  63. }
  64. ]),
  65. new AssetsPlugin({
  66. filename: "webpack.json",
  67. path: path.join(process.cwd(), "site/data"),
  68. prettyPrint: true
  69. })
  70. ]
  71. };
  72.  
  73. const merge = require("webpack-merge");
  74. const TerserPlugin = require('terser-webpack-plugin');
  75. const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
  76. const MiniCssExtractPlugin = require("mini-css-extract-plugin");
  77. const common = require("./webpack.common.js");
  78. const {InjectManifest, GenerateSW} = require('workbox-webpack-plugin');
  79.  
  80. module.exports = merge(common, {
  81. mode: "production",
  82.  
  83. output: {
  84. filename: "[name].[hash:5].js",
  85. chunkFilename: "[id].[hash:5].css"
  86. },
  87.  
  88. optimization: {
  89. minimizer: [
  90. new TerserPlugin({
  91. cache: true,
  92. parallel: true,
  93. sourceMap: true
  94. }),
  95.  
  96. new MiniCssExtractPlugin({
  97. filename: "[name].[hash:5].css",
  98. chunkFilename: "[id].[hash:5].css"
  99. }),
  100.  
  101. new OptimizeCSSAssetsPlugin({}),
  102. ]
  103. },
  104. plugins: [
  105. new InjectManifest({
  106. swSrc: './src/sw.js',
  107. exclude: [/.md$/, /.xml$/, /.txt$/, /.json$/, /.keep$/, /.DS_Store$/, '404.html', '404/index.html']
  108. }),
  109. ]
  110. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement