-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
140 lines (138 loc) · 3.39 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
const path = require('path')
const html = require('html-webpack-plugin')
const copy = require('copy-webpack-plugin')
const extractCSS = require('mini-css-extract-plugin')
const {VueLoaderPlugin} = require('vue-loader')
const ESLint = require('eslint-webpack-plugin')
const SLint = require('stylelint-webpack-plugin')
const config = (DEV_MODE) => {return {
entry: {
main: './src/main.js',
},
devServer: {
hot: true,
headers: {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp'
}
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'html'),
clean: true
},
resolve: {
alias: {
'assets': path.resolve(__dirname, 'src/assets/'),
'stores': path.resolve(__dirname, 'src/stores/'),
'utils': path.resolve(__dirname, 'src/utils/'),
'router': path.resolve(__dirname, 'src/router.js'),
'controls': path.resolve(__dirname, 'src/controls/'),
'components': path.resolve(__dirname, 'src/components/'),
},
extensions: ['.js', '.vue']
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.styl(us)?$/i,
use: [
extractCSS.loader,
{
loader: 'css-loader',
options: {
sourceMap: DEV_MODE
}
},
{
loader: 'stylus-loader',
options: {
sourceMap: DEV_MODE
}
}
],
},
{
test: /\.css$/i,
use: [
extractCSS.loader,
{
loader: 'css-loader',
options: {
sourceMap: DEV_MODE
}
}
],
},
{
test: /\.(gif|png|jpe?g|svg)$/i,
use: [
{
loader: 'file-loader',
options: {
name: 'assets/[name].[ext]',
esModule: false
}
}
]
}
]
},
plugins: [
new ESLint({
extensions: ['js', 'vue']
}),
new SLint({
files: ['**/*.{vue,css,stylus}'],
}),
new VueLoaderPlugin(),
new extractCSS(),
new html({
templateContent: ({htmlWebpackPlugin}) => `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>${htmlWebpackPlugin.options.title}</title>
</head>
<body>
</body>
</html>
`,
title: 'BEAM NFT Gallery',
favicon: './src/appicon.svg',
scriptLoading: 'blocking',
meta: {
viewport: 'width=device-width,initial-scale=1.0',
},
}),
new copy({
patterns: [
'./src/galleryManager.wasm',
'./src/appicon.svg',
{
from: 'assets/**/*',
context: './src'
},
{
from: path.join(__dirname, './node_modules/beam-wasm-client-dappnet/'),
globOptions: {
ignore: ['**/package.json', '**/README.md'],
},
}
]
})
],
devtool: DEV_MODE ? 'source-map' : undefined
}}
module.exports = (env, argv) => {
const mode = argv.mode
console.log('Mode:', mode)
const DEV_MODE = mode == 'development'
return config(DEV_MODE)
}