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

webpack.config.js 3.1KB

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