Adrià Vilanova Martínez | e877a00 | 2021-09-03 22:03:01 +0200 | [diff] [blame] | 1 | const webpack = require('webpack'); |
Adrià Vilanova Martínez | f7ee658 | 2021-09-02 21:53:28 +0200 | [diff] [blame] | 2 | const path = require('path') |
| 3 | const json5 = require('json5'); |
| 4 | const {VueLoaderPlugin} = require('vue-loader'); |
| 5 | const HtmlWebpackPlugin = require('html-webpack-plugin'); |
| 6 | |
| 7 | module.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ínez | e877a00 | 2021-09-03 22:03:01 +0200 | [diff] [blame] | 51 | new webpack.DefinePlugin({ |
| 52 | 'PRODUCTION': args.mode == 'production', |
| 53 | }), |
Adrià Vilanova Martínez | f7ee658 | 2021-09-02 21:53:28 +0200 | [diff] [blame] | 54 | ], |
| 55 | devServer: { |
| 56 | static: './dist', |
| 57 | }, |
| 58 | devtool: (args.mode == 'production' ? 'source-map' : 'inline-source-map'), |
| 59 | }; |
| 60 | }; |