materio-d9/build/webpack.config.base.js

132 lines
3.4 KiB
JavaScript
Raw Permalink Normal View History

'use strict'
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { VueLoaderPlugin } = require('vue-loader')
const ESLintPlugin = require('eslint-webpack-plugin');
2021-01-25 22:19:21 +01:00
const ExtraneousFileCleanupPlugin = require('webpack-extraneous-file-cleanup-plugin');
const utils = require('./utils')
const themePath = 'web/themes/custom/materiotheme'
module.exports = {
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue': 'vue/dist/vue.js',
'theme': utils.resolve(themePath),
'vuejs': utils.resolve(themePath+'/vuejs'),
'assets': utils.resolve(themePath+'/assets'),
// locales are exported by strings_i18n_json_export from drupal
'locales': utils.resolve('web/sites/default/files/lang')
}
},
entry: {
'main': utils.resolve(themePath + '/assets/scripts/main.js'),
2021-01-25 22:19:21 +01:00
'print': utils.resolve(themePath + '/assets/styles/print.scss')
},
output: {
path: utils.resolve(themePath + '/assets/dist/'),
filename: '[name].js'
},
module: {
rules: [
// {
// test: /\.(js|vue)$/,
// loader: 'eslint-loader',
// enforce: 'pre',
// exclude: /node_modules/,
// options: {
// emitError: true,
// emitWarning: true
// }
// },
{
test: /\.vue$/,
use: 'vue-loader'
},
// {
// resourceQuery: /blockType=i18n/,
// type: 'javascript/auto',
// loader: '@kazupon/vue-i18n-loader'
// },
{
test: /\.js$/,
use: {
loader: 'babel-loader',
}
},
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader'
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
}
// {
// test: /\.graphql?$/,
// use: [
// {
// loader: 'webpack-graphql-loader',
// options: {
// // validate: true,
// // schema: "./path/to/schema.json",
// // removeUnusedFragments: true
// // etc. See "Loader Options" below
// }
// }
// ]
// }
// , {
// test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
// use: {
// loader: 'url-loader',
// options: {
// limit: 10000,
// name: utils.assetsPath('img/[name].[hash:7].[ext]')
// }
// }
// }, {
// test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
// use: {
// loader: 'url-loader',
// options: {
// limit: 10000,
// name: utils.assetsPath('media/[name].[hash:7].[ext]')
// }
// }
// }
2021-01-25 22:19:21 +01:00
// {
// test: /\.css$/,
// use: [MiniCssExtractPlugin.loader, 'css-loader'],
// },
]
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css'
}),
new VueLoaderPlugin(),
new ESLintPlugin({
2020-11-26 22:46:01 +01:00
// fix: true
// exclude: ['web/.eslintrc.json']
// cache: false,
// ignore: true,
// useEslintrc: false,
2021-01-25 22:19:21 +01:00
}),
new ExtraneousFileCleanupPlugin({
extensions: ['.js'],
paths: [utils.resolve(themePath + '/assets/dist/')],
minBytes: 4096
})
]
}