blob: 005f361d3d293b3b6476df6a51ca8d4fe32bf3d5 [file] [log] [blame]
Adrià Vilanova Martíneze877a002021-09-03 22:03:01 +02001const webpack = require('webpack');
Adrià Vilanova Martínezf7ee6582021-09-02 21:53:28 +02002const path = require('path')
3const json5 = require('json5');
4const {VueLoaderPlugin} = require('vue-loader');
5const HtmlWebpackPlugin = require('html-webpack-plugin');
6
7module.exports = (env, args) => {
8 return {
9 entry: './src/main.js',
10 output: {
11 filename: '[name].[contenthash:8].bundle.js',
12 path: path.resolve(__dirname, './dist'),
13 clean: true,
14 },
15 module: {
16 rules: [
17 {
18 test: /\.vue$/,
19 loader: 'vue-loader',
20 },
21 {
22 test: /\.s[ac]ss$/,
23 use: [
24 'vue-style-loader',
25 'css-loader',
26 'sass-loader',
27 ],
28 },
29 {
30 test: /\.css$/,
31 use: [
32 'vue-style-loader',
33 'css-loader',
34 ],
35 },
36 {
37 test: /\.json5$/,
38 type: 'json',
39 parser: {
40 parse: json5.parse,
41 },
42 }
43 ],
44 },
45 plugins: [
46 new VueLoaderPlugin(),
47 new HtmlWebpackPlugin({
48 filename: 'index.html',
49 template: 'index.html',
50 }),
Adrià Vilanova Martíneze877a002021-09-03 22:03:01 +020051 new webpack.DefinePlugin({
52 'PRODUCTION': args.mode == 'production',
53 }),
Adrià Vilanova Martínezf7ee6582021-09-02 21:53:28 +020054 ],
55 devServer: {
56 static: './dist',
57 },
58 devtool: (args.mode == 'production' ? 'source-map' : 'inline-source-map'),
59 };
60};