-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathwebpack.common.js
65 lines (63 loc) · 2.06 KB
/
webpack.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
const path = require('path');
const { glob } = require('glob');
const ESLintPlugin = require('eslint-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
entry: {
inject: './src/inject.js',
index: './src/index.js',
bundle: [
...glob.sync('./src/modules/**/index.@(css|scss)').filter((path) => !path.includes('.module.')),
...glob.sync('./src/utils/**/index.@(css|scss)').filter((path) => !path.includes('.module.')),
],
content: [...glob.sync('./src/content/*.js')],
worker: [...glob.sync('./src/worker/*.js')],
},
resolve: {
alias: {
$Modules: path.resolve(__dirname, 'src/modules'),
$Utils: path.resolve(__dirname, 'src/utils'),
$Logger: path.resolve(__dirname, 'src/common/logger.js'),
$Peeker: path.resolve(__dirname, 'src/common/peeker.js'),
$Settings: path.resolve(__dirname, 'src/common/settings.js'),
},
extensions: ['.js', '.jsx'],
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'build'),
clean: true,
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
loader: 'webpack-glob-loader',
exclude: /node_modules/,
enforce: 'pre',
},
{
test: /\.(js|jsx)?$/,
use: ['babel-loader'],
exclude: /node_modules/,
},
{
test: /\.(scss|css)$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
},
],
},
plugins: [
new ESLintPlugin({
extensions: ['js', 'jsx'],
overrideConfigFile: path.resolve(__dirname, '.eslintrc'),
}),
new MiniCssExtractPlugin({
filename: '[name].css',
}),
new CopyPlugin({
patterns: [{ from: 'public' }],
}),
],
};