NEXT craftinamerica.org. Base setup for headless wordpress https://www.craftinamerica.org
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

webpack.config.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. const path = require('path')
  2. const webpack = require('webpack')
  3. const { VueLoaderPlugin } = require('vue-loader')
  4. const CompressionPlugin = require('compression-webpack-plugin')
  5. const PostCssPlugins = [
  6. require('postcss-import'),
  7. require('precss'),
  8. require('autoprefixer')
  9. ]
  10. module.exports = (env = {}) => {
  11. return {
  12. mode: env.production ? 'production' : 'development',
  13. resolve: {
  14. alias: {
  15. '@': path.resolve(__dirname, 'src'),
  16. },
  17. extensions: ['*', '.js', '.sss', '.vue', '.json']
  18. },
  19. module: {
  20. rules: [{
  21. test: /\.vue$/,
  22. use: ['vue-loader']
  23. },
  24. {
  25. test: /\.(js)$/,
  26. loader: 'babel-loader',
  27. exclude: /node_modules/
  28. },
  29. {
  30. test: /\.pug$/,
  31. oneOf: [
  32. // this applies to `<template lang="pug">` in Vue components
  33. {
  34. resourceQuery: /^\?vue/,
  35. use: ['pug-plain-loader']
  36. }
  37. ]
  38. },
  39. {
  40. test: /\.(png|jpg|gif|svg|ttf|woff2|woff)$/,
  41. loader: 'url-loader',
  42. options: {
  43. limit: 10000,
  44. name: '[name].[ext]?[hash]'
  45. }
  46. },
  47. {
  48. test: /(\.html$|favicon)/,
  49. loader: 'file-loader',
  50. options: {
  51. name: '[name].[ext]'
  52. }
  53. },
  54. {
  55. test: /\.(css|sss|postcss)$/,
  56. use: [
  57. 'style-loader',
  58. 'css-loader',
  59. 'postcss-loader',
  60. ]
  61. }
  62. ]
  63. },
  64. output: {
  65. path: path.join(__dirname, 'build'),
  66. publicPath: '/build/'
  67. },
  68. // https://github.com/Tech-Nomad/wue-theme
  69. devServer: {
  70. publicPath: "/build/",
  71. https: false,
  72. inline: true,
  73. noInfo: false,
  74. historyApiFallback: true,
  75. hot: true,
  76. open: false,
  77. hotOnly: true,
  78. disableHostCheck: true,
  79. writeToDisk: true,
  80. proxy: {
  81. '/': {
  82. target: "http://localhost:8080",
  83. secure: false,
  84. changeOrigin: true,
  85. autoRewrite: true,
  86. headers: {
  87. 'X-ProxiedBy-Webpack': true,
  88. },
  89. },
  90. },
  91. },
  92. devtool: env.production ? false : 'cheap-module-eval-source-map',
  93. plugins: [
  94. new webpack.DefinePlugin({
  95. PRODUCTION: JSON.stringify(env.production)
  96. }),
  97. new VueLoaderPlugin(),
  98. new CompressionPlugin({ threshold: 8192 }),
  99. new webpack.HotModuleReplacementPlugin()
  100. ]
  101. }
  102. }