Задать вопрос
Vadimir200017
@Vadimir200017
Закончил колледж и ищу работу.

Как использовать js плагин mysql в сборке gulp?

webpack.config.js
export const config = {
  mode: "production",
  entry: {
    index: "./src/js/index.js",
    training: "./src/js/training.js"
  },
  output: {
    filename: "[name].js"
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader"],
      },
    ],
  },
  resolve: {
    fallback: {
      crypto: import.meta.resolve("crypto-browserify"),
    },
  },
}


package.json
{
  "name": "layouts-pattern",
  "version": "1.0.0",
  "description": "Ready-made template for layout",
  "main": "gulpfile.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Vladimir Balasyan",
  "license": "ISC",
  "devDependencies": {
    "browser-sync": "^2.28.1",
    "css-loader": "^6.8.1",
    "gulp": "^4.0.2",
    "gulp-avif": "^1.1.1",
    "gulp-clean": "^0.4.0",
    "gulp-file-include": "^2.3.0",
    "gulp-fonter": "^0.3.0",
    "gulp-htmlmin": "^5.0.1",
    "gulp-imagemin": "^7.1.0",
    "gulp-newer": "^1.4.0",
    "gulp-sass": "^5.1.0",
    "gulp-ttf2woff2": "^4.0.1",
    "gulp-version-number": "^0.2.4",
    "gulp-webp": "^4.0.1",
    "sass": "^1.58.3",
    "style-loader": "^3.3.3",
    "webpack-stream": "^7.0.0"
  },
  "dependencies": {
    "crypto-browserify": "^3.12.1",
    "mysql": "^2.18.1"
  }
}


gulpfile.js
import gulp from "gulp";
import browsersync from "browser-sync";
import { cleanDist } from "./tasks/clean.js";
import { html } from "./tasks/html.js";
import { scss } from "./tasks/scss.js";
import { js } from "./tasks/js.js";
import { img } from "./tasks/img.js";
import { iconsFont } from "./tasks/icons.font.js";
import * as fonts from "./tasks/fonts.js";

global.app = {
  gulp: gulp,
  browsersync: browsersync,
}

function watch() {
  gulp.watch(["./src/**/*.html"], html)
  gulp.watch(["./src/scss/**/*.scss"], scss)
  gulp.watch(["./src/js/**/*.js"], js)
  gulp.watch(["./src/img/**/*.*"], img)
}

function browserSync() {
  browsersync.init({
    server: { baseDir: "./dist/" }
  })
}

const createFontsFiles =
  gulp.series(fonts.convertFonts, fonts.createFontsFile);
const parallel =
  gulp.parallel(html, scss, js, img, createFontsFiles, iconsFont)
const browser =
  gulp.parallel(watch, browserSync);

gulp.task(
  "default",
  gulp.series(cleanDist, parallel, browser)
);
  • Вопрос задан
  • 66 просмотров
Подписаться 1 Простой 3 комментария
Пригласить эксперта
Ответы на вопрос 1
Fzero0
@Fzero0
Вечный студент
MySQL - это серверная технология, и прямое её использование в браузере невозможно
MySQL работает только на сервере (Node.js), а не в браузере
Вы пытаетесь через Webpack собрать MySQL для браузера?
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы