webpack.config.base.js 3.0 KB

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