webpack.config.base.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. 'use strict'
  2. const MiniCssExtractPlugin = require("mini-css-extract-plugin");
  3. const { VueLoaderPlugin } = require('vue-loader')
  4. const ESLintPlugin = require('eslint-webpack-plugin');
  5. const ExtraneousFileCleanupPlugin = require('webpack-extraneous-file-cleanup-plugin');
  6. const utils = require('./utils')
  7. const themePath = 'web/themes/custom/materiotheme'
  8. module.exports = {
  9. resolve: {
  10. extensions: ['.js', '.vue', '.json'],
  11. alias: {
  12. 'vue': 'vue/dist/vue.js',
  13. 'theme': utils.resolve(themePath),
  14. 'vuejs': utils.resolve(themePath+'/vuejs'),
  15. 'assets': utils.resolve(themePath+'/assets'),
  16. // locales are exported by strings_i18n_json_export from drupal
  17. 'locales': utils.resolve('web/sites/default/files/lang')
  18. }
  19. },
  20. entry: {
  21. 'main': utils.resolve(themePath + '/assets/scripts/main.js'),
  22. 'print': utils.resolve(themePath + '/assets/styles/print.scss')
  23. },
  24. output: {
  25. path: utils.resolve(themePath + '/assets/dist/'),
  26. filename: '[name].js'
  27. },
  28. module: {
  29. rules: [
  30. // {
  31. // test: /\.(js|vue)$/,
  32. // loader: 'eslint-loader',
  33. // enforce: 'pre',
  34. // exclude: /node_modules/,
  35. // options: {
  36. // emitError: true,
  37. // emitWarning: true
  38. // }
  39. // },
  40. {
  41. test: /\.vue$/,
  42. use: 'vue-loader'
  43. },
  44. // {
  45. // resourceQuery: /blockType=i18n/,
  46. // type: 'javascript/auto',
  47. // loader: '@kazupon/vue-i18n-loader'
  48. // },
  49. {
  50. test: /\.js$/,
  51. use: {
  52. loader: 'babel-loader',
  53. }
  54. },
  55. {
  56. test: /\.(graphql|gql)$/,
  57. exclude: /node_modules/,
  58. loader: 'graphql-tag/loader'
  59. }
  60. // {
  61. // test: /\.graphql?$/,
  62. // use: [
  63. // {
  64. // loader: 'webpack-graphql-loader',
  65. // options: {
  66. // // validate: true,
  67. // // schema: "./path/to/schema.json",
  68. // // removeUnusedFragments: true
  69. // // etc. See "Loader Options" below
  70. // }
  71. // }
  72. // ]
  73. // }
  74. // , {
  75. // test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  76. // use: {
  77. // loader: 'url-loader',
  78. // options: {
  79. // limit: 10000,
  80. // name: utils.assetsPath('img/[name].[hash:7].[ext]')
  81. // }
  82. // }
  83. // }, {
  84. // test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
  85. // use: {
  86. // loader: 'url-loader',
  87. // options: {
  88. // limit: 10000,
  89. // name: utils.assetsPath('media/[name].[hash:7].[ext]')
  90. // }
  91. // }
  92. // }, {
  93. // test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  94. // use: {
  95. // loader: 'url-loader',
  96. // options: {
  97. // limit: 10000,
  98. // name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  99. // }
  100. // }
  101. // }
  102. // {
  103. // test: /\.css$/,
  104. // use: [MiniCssExtractPlugin.loader, 'css-loader'],
  105. // },
  106. ]
  107. },
  108. plugins: [
  109. new MiniCssExtractPlugin({
  110. filename: '[name].css'
  111. }),
  112. new VueLoaderPlugin(),
  113. new ESLintPlugin({
  114. // fix: true
  115. // exclude: ['web/.eslintrc.json']
  116. // cache: false,
  117. // ignore: true,
  118. // useEslintrc: false,
  119. }),
  120. new ExtraneousFileCleanupPlugin({
  121. extensions: ['.js'],
  122. paths: [utils.resolve(themePath + '/assets/dist/')],
  123. minBytes: 4096
  124. })
  125. ]
  126. }