-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.config.ts
67 lines (64 loc) · 1.73 KB
/
webpack.common.config.ts
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
import path from 'path';
import globule from 'globule';
import webpack from 'webpack';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import RemoveEmptyScriptsPlugin from 'webpack-remove-empty-scripts';
import ProjectConfig from './project.config';
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
const {src, dist} = process.env;
const commonConfig: webpack.Configuration = {
entry: ProjectConfig.entries,
output: {
filename: "[name].js",
path: path.resolve(dist!),
},
module: {
rules: [
{
test: /\.svg$/,
use: ["svg-sprite-loader", "svg-transform-loader", "svgo-loader"],
},
{
test: /\.(js|ts|jsx|tsx)$/,
exclude: /node_modules/,
use: [
{
loader: "babel-loader",
options: {
cacheDirectory: true,
cacheCompression: false,
},
},
],
},
],
},
// externals: {
// jquery: "jQuery",
// },
resolve: {
plugins: [new TsconfigPathsPlugin({})],
modules: ["node_modules", path.resolve(src!, "scripts/")],
extensions: ['.ts', '.tsx', '.jsx', '.js', '.css', '.scss', '.json'],
},
performance: { hints: false },
plugins: [
new RemoveEmptyScriptsPlugin({enabled: true}),
new MiniCssExtractPlugin({
filename: "[name]",
}),
new CopyWebpackPlugin({
patterns: [
{ from: path.resolve(src!, "images"), to: dist },
// { from: path.resolve(src, "fonts"), to: "fonts/" },
],
}),
// new webpack.ProvidePlugin({
// $: "jquery",
// jQuery: "jquery",
// "window.jQuery": "jquery",
// }),
],
};
export default commonConfig;