NEXT craftinamerica.org. Base setup for headless wordpress https://www.craftinamerica.org
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

webpack.config.js 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. 'vue$': 'vue/dist/vue.esm.js'
  17. },
  18. extensions: ['*', '.js', '.sss', '.vue', '.json']
  19. },
  20. module: {
  21. rules: [{
  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: [{
  58. loader: 'vue-style-loader'
  59. },
  60. {
  61. loader: 'postcss-loader',
  62. options: {
  63. parser: 'sugarss',
  64. plugins: () => {
  65. return PostCssPlugins
  66. }
  67. }
  68. }
  69. ]
  70. }
  71. ]
  72. },
  73. output: {
  74. path: path.join(__dirname, 'build'),
  75. publicPath: '/build/'
  76. },
  77. // https://github.com/Tech-Nomad/wue-theme
  78. devServer: {
  79. publicPath: "/build/",
  80. https: false,
  81. inline: true,
  82. noInfo: false,
  83. historyApiFallback: true,
  84. hot: true,
  85. open: true,
  86. hotOnly: true,
  87. disableHostCheck: true,
  88. writeToDisk: true,
  89. proxy: {
  90. '/': {
  91. target: "http://localhost:8080",
  92. secure: false,
  93. changeOrigin: true,
  94. autoRewrite: true,
  95. headers: {
  96. 'X-ProxiedBy-Webpack': true,
  97. },
  98. },
  99. },
  100. },
  101. devtool: env.production ? false : 'cheap-module-eval-source-map',
  102. plugins: [
  103. new webpack.DefinePlugin({
  104. PRODUCTION: JSON.stringify(env.production)
  105. }),
  106. new VueLoaderPlugin(),
  107. new CompressionPlugin({ threshold: 8192 }),
  108. new webpack.HotModuleReplacementPlugin()
  109. ]
  110. }
  111. }