-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.babel.js
More file actions
79 lines (76 loc) · 2.28 KB
/
webpack.config.babel.js
File metadata and controls
79 lines (76 loc) · 2.28 KB
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
import { ProgressPlugin } from 'webpack';
import FriendlyErrorsWebpackPlugin from 'friendly-errors-webpack-plugin';
import webpackMerge from 'webpack-merge';
import WebpackBar from 'webpackbar';
import DuplicatePackageCheckerPlugin from 'duplicate-package-checker-webpack-plugin';
import CleanWebpackPlugin from 'clean-webpack-plugin';
import { resolve } from 'path';
import { loader as _loader } from 'mini-css-extract-plugin';
import presetConfig from './build-utils/loadPresets';
const StyleLintPlugin = require('stylelint-webpack-plugin');
const modeConfig = (env) => require(`./build-utils/webpack.${env}`)(env); //eslint-disable-line
export default ({ mode, presets } = { mode: 'production', presets: [] }) =>
webpackMerge(
{
mode,
entry: {
index: './src/js/index.js',
},
output: {
path: resolve(__dirname, 'arquivos'),
filename: '[name].bundle.js',
chunkFilename: '[name].bundle.js',
publicPath: '/arquivos/',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: ['babel-loader', 'eslint-loader'],
},
{
test: /\.pug$/,
use: ['pug-loader'],
exclude: [resolve(__dirname, 'src/templates/*')],
},
{
test: /\.(css)$/,
include: /node_modules/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(scss)$/,
use: [_loader, 'css-loader', 'postcss-loader', 'sass-loader'],
},
],
},
plugins: [
new CleanWebpackPlugin(),
new FriendlyErrorsWebpackPlugin(),
new DuplicatePackageCheckerPlugin(),
new ProgressPlugin(),
new WebpackBar(),
new StyleLintPlugin({
content: './src/scss/main.scss',
configFile: '.stylelintrc',
fix: true,
syntax: 'scss',
failOnError: false,
}),
],
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
},
},
},
},
},
modeConfig(mode),
presetConfig({ mode, presets }),
);