This repository has been archived by the owner on Nov 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
82 lines (80 loc) · 2.03 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const path = require('path');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = (env, argv) => {
const isProduction = argv.mode === 'production';
return {
context: path.resolve(__dirname, 'app/javascript/packs'),
entry: [
'pages/tasks/index'
].reduce((obj, key) => {
obj[key] = [
'@babel/polyfill',
path.resolve(__dirname, 'app/javascript/packs', key)
];
return obj;
}, {}),
output: {
path: path.resolve(__dirname, 'public/packs'),
filename: isProduction ? '[name]-[contentHash].js' : '[name]-[hash].js',
},
module: {
rules: [
{test: /\.(css|sass|scss)$/, use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'file-loader',
options: {
outputPath: 'images/',
name: '[name]-[hash].[ext]',
},
},
],
},
{
test: /\.vue$/,
exclude: /node_modules/,
loader: 'vue-loader',
options: {
extractCSS: true,
},
},
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
options: { appendTsSuffixTo: [/\.vue$/] }
}
]
},
{
test: /\.(pug)$/i,
oneOf: [
{
resourceQuery: /^\?vue/,
use: 'pug-plain-loader'
},
{
use: 'pug-loader'
}
]
},
],
},
plugins: [
new VueLoaderPlugin(),
new ManifestPlugin(),
new MiniCssExtractPlugin({filename: '[name]-[contentHash].css'}),
],
devServer: {
publicPath: '/packs/',
historyApiFallback: true,
port: 3035,
},
};
}