-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
155 lines (146 loc) · 3.85 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
const webpack = require('webpack');
const { resolve } = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpackMerge = require('webpack-merge');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const path = require('path');
const modeConfig = env => require(`./build-utils/webpack.${env.mode}.js`)(env);
const loadPresets = require('./build-utils/loadPresets');
const webcomponentsjs = './node_modules/@webcomponents/webcomponentsjs';
const polyfills = [
{
from: resolve(`${webcomponentsjs}/webcomponents-*.{js,map}`),
to: 'vendor',
flatten: true
},
{
from: resolve(`${webcomponentsjs}/bundles/*.{js,map}`),
to: 'vendor/bundles',
flatten: true
},
{
from: resolve(`${webcomponentsjs}/custom-elements-es5-adapter.js`),
to: 'vendor',
flatten: true
}
];
const assets = [
{
from: 'src/libs',
to: 'libs/'
},
{
from: 'src/img',
to: 'img/'
},
{
from: 'src/agents',
to: 'agents/'
},
{
from: 'src/css',
to: 'css/'
},
{
from: 'src/dist-popup',
to: 'dist-popup/'
},
'src/manifest.json'
];
const plugins = [
new CleanWebpackPlugin(['dist']),
new webpack.ProgressPlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/index.html',
minify: {
collapseWhitespace: true,
// minifyCSS: true,
minifyJS: true
}
}),
new CopyWebpackPlugin([...polyfills, ...assets], {
ignore: ['.DS_Store']
})
];
module.exports = ({ mode, presets }) => {
return webpackMerge(
{
mode,
externals: {
'@solid/query-ldflex': {
root: ['solid', 'data'],
commonjs: '@solid/query-ldflex', // not used, but needed for config
commonjs2: '@solid/query-ldflex', // not used, but needed for config
},
},
/* entry: {
"main": './src/index.js',
"store-element": './src/views/store-element.js',
},
"info-element": './src/views/info-element.js',
"login-element": './src/views/login-element.js',
"post-element": './src/views/post-element.js',
"fab-element": './src/views/fab-element.js',
"profile-cartouche-element": './src/views/profile-cartouche-element.js',
},*/
/* entry: {
"app-view": './src/views/app-view.js',
"login-element": './src/views/login-element.js',
"store-element": './src/views/store-element.js',
"info-element": './src/views/info-element.js',
"post-element": './src/views/post-element.js',
"flux-element": './src/views/flux-element.js',
"friends-view": './src/views/friends-view.js',
"friend-view": './src/views/friend-view.js',
"notification-line-element": './src/views/notification-line-element.js',
"activity-element": './src/views/activity-element.js',
"object-element": './src/views/object-element.js',
"profile-cartouche-element": './src/views/profile-cartouche-element.js',
"fab-element": './src/views/fab-element.js',
},*/
output: {
//filename: '[name].[hash:8].js'
filename: 'views/[name].js',
},
devServer: {
contentBase: path.join(__dirname, 'dist'),
compress: true,
port: 9000,
historyApiFallback: true,
inline: true,
open: true,
hot: true
},
devtool: "eval-source-map",
performance: {
hints: false
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
plugins: ['@babel/plugin-syntax-dynamic-import'],
presets: [
[
'@babel/preset-env',
{
useBuiltIns: 'usage',
targets: '>1%, not dead, not ie 11'
}
]
]
}
}
]
},
plugins
},
modeConfig({ mode, presets }),
loadPresets({ mode, presets })
);
};