-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebpack.config.js
More file actions
77 lines (74 loc) · 2.59 KB
/
webpack.config.js
File metadata and controls
77 lines (74 loc) · 2.59 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
/* eslint-env node */
const path = require("path");
const fs = require("fs");
const webpack = require("webpack");
const { VueLoaderPlugin } = require("vue-loader");
const ESLintPlugin = require('eslint-webpack-plugin');
// Path to your javascript folder
const javascriptsDir = path.resolve(__dirname, "app/javascript");
// Find all .js files in the app/javascript directory
const entries = fs.readdirSync(javascriptsDir)
.filter(file => file.endsWith(".js"))
.reduce((acc, file) => {
const name = file.replace(/\.js$/, "");
acc[name] = path.join(javascriptsDir, file);
return acc;
}, {});
module.exports = {
mode: process.env.NODE_ENV || "development",
devtool: process.env.NODE_ENV === "production" ? "hidden-source-map" : "source-map",
// Use our dynamically generated entries object
entry: entries,
output: {
filename: "[name].js",
sourceMapFilename: "[name].js.map",
path: path.resolve(__dirname, "app/assets/builds"),
// emit original names so Sprockets can add the single fingerprint
assetModuleFilename: "[name][ext]"
},
plugins: [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
new VueLoaderPlugin(),
new ESLintPlugin({
extensions: ['js', 'jsx', 'vue'], // Specify file extensions to check (including .vue for your project)
exclude: ['node_modules'], // Directories to exclude (defaults to node_modules)
formatter: 'stylish', // Use the 'stylish' formatter (or any other you prefer)
emitError: true, // Report ESLint errors as webpack errors
emitWarning: true, // Report ESLint warnings as webpack warnings
failOnError: process.env.NODE_ENV === "production", // Make the build fail on ESLint errors
cache: true, // Enable caching for faster linting
cacheLocation: path.resolve(__dirname, 'node_modules/.cache/.eslintcache'), // Custom cache location
fix: false, // Set to true to automatically fix linting issues (use with caution in CI)
lintDirtyModulesOnly: process.env.NODE_ENV !== "production", // Only lint changed files (set to true for faster incremental builds)
}),
],
module: {
rules: [
{
test: /\.vue$/,
loader: "vue-loader",
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader"],
},
{
test: /\.css$/,
use: ['vue-style-loader', 'css-loader']
},
{
test: /\.(woff|woff2|eot|ttf|otf|svg)$/i,
type: 'asset/resource',
}
],
},
resolve: {
extensions: [".js", ".vue"],
alias: {
vue$: 'vue/dist/vue.esm.js'
}
},
};