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