Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Начинаем программировать #3

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Thumbs.db
node_modules/

# Собранные файлы (допишите самостоятельно)
/build
46 changes: 44 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,58 @@

{
"name": "big-trip",
"version": "19.0.0",
"private": true,
"description": "Проект «Большое путешествие» от HTML Academy",
"main": "main.js",

"scripts": {
"lint": "eslint src/"
"lint": "eslint src/",
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack --mode production",
"start": "webpack serve --mode development --open"
},

"repository":{
"type": "git",
"url": "https://github.com/DashaKukartseva/2433045-big-trip-4"
},

"dependencies": {
"dayjs": "^1.11.6",
"flatpickr": "^4.6.13",
"he": "^1.2.0"
},

"devDependencies": {
"eslint": "8.28.0",
"eslint-config-htmlacademy": "8.0.0"
"eslint-config-htmlacademy": "8.0.0",
"@babel/core": "^7.24.0",
"@babel/preset-env": "^7.24.0",
"babel-loader": "^9.1.3",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.7.2",
"html-webpack-plugin": "^5.6.0",
"style-loader": "^3.3.1",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.0",
"webpack-dev-server": "^4.11.1"
},

"engines": {
"node": "18"
},

"browserslist":{
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
73 changes: 73 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const path = require('path'); // Импортируем модуль "path" для работы с путями файлов
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');


module.exports = {
entry: './src/main.js', // Точка входа для сборки проекта
output: {
filename: 'bundle.[contenthash].js', // Имя выходного файла сборки
path: path.resolve(__dirname, 'build'), // Путь для выходного файла сборки
clean: {
// сохранение файлов
keep: /\ignored\/dir\//
}
},

module: {
rules: [
{
test: /\.css$/, // Регулярное выражение для обработки файлов с расширением .css
use: ['style-loader', 'css-loader'], // Загрузчики, используемые для обработки CSS-файлов
},
],
},

module: {
rules: [
{
test: /\.js$/, // применять загрузчик только к файлам .js
exclude: /node_modules/, // не применять загрузчик к файлам в папке node_modules
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
},

devtool: 'source-map', // Здесь задаем создание карт
module: {
rules: [{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: { sourceMaps: true } // Командуем Babel создавать карты
}
}]},

plugins: [
new HtmlWebpackPlugin({
template: './src/index.html',
ignore: ['index.html']
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, './src/public'),
to: path.resolve(__dirname, './src/build')
}
]})
],

devServer: {
static: {
directory: path.join(__dirname, 'dist'), // Каталог для статики
},
open: true, // Автоматически открывать браузер
},

mode: 'development', // Режим сборки
};
Loading