-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.common.js
74 lines (73 loc) · 2.42 KB
/
webpack.config.common.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
const CopyPlugin = require('copy-webpack-plugin');
const DotEnv = require('dotenv-webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const webpack = require('webpack');
module.exports = function(mode, eternajs_copy) {
return {
mode: mode,
devtool: 'inline-source-map',
entry: './src/main.ts',
output: {
path: path.resolve(__dirname, 'www'),
filename: 'bundle.js?[chunkHash]',
chunkFilename: '[name].js?[chunkHash]',
assetModuleFilename: '[name].[ext]?[hash]'
},
resolve: {
extensions: ['.ts', '.js', '.vue', '.json'],
},
module: {
rules: [
{
test: /\.ts$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
appendTsSuffixTo: [/\.vue$/],
}
},
{
test: /\.s[ac]ss$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader',
],
},
{
test: /\.vue$/,
loader: 'vue-loader',
},
{
test: /\.(png|jpg|gif|svg|mp4)$/,
type: 'asset/resource'
},
],
},
plugins: [
new DotEnv({
defaults: './.env',
path: './.env.local',
silent: true,
systemvars: true
}),
new HtmlWebpackPlugin({
inject: false,
meta: {
viewport: 'initial-scale=1, maximum-scale=1, user-scalable=0, width=device-width, viewport-fit=cover',
},
templateParameters: { mode }
}),
new VueLoaderPlugin(),
new CopyPlugin({patterns: [
...(process.env.PARALLEL_BUILD ? [] : [{ context: eternajs_copy, from: '**/*', to: 'eternajs/'}]),
{ from: 'src/assets/favicon.ico', to: 'favicon.ico'},
]}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(mode)
})
],
};
};