Я пытаюсь добавить https://github.com/themeblvd/frontstreet frontstreet framework в Wordpress.
У меня есть предварительно созданный ресурс "frontstreet.js" в wp-content / themes / front-theme / js / frontstreet. js В той же локализации я поместил свой собственный файл "scripts.js" для импорта модулей. Для теста я набираю alert
import $ from 'jquery';
alert("test");
Я запускаю сайт gulp watch, и он работает должным образом, с фреймворковыми CSS-классами. Но никакое предупреждение и консоль не показывают никакой ошибки. Я думаю, что gulp не видит мой файл "scripts.js".
EDIT В терминале у меня ошибка:
ОШИБКА в модуле ввода не найдена: Ошибка: может't resol' ./wp-content/themes/front-theme/js/scritps.js 'in' / Applications / MAMP / htdocs / front '
Настройки Gulp:
var gulp = require('gulp'),
settings = require('./settings'),
webpack = require('webpack'),
browserSync = require('browser-sync').create(),
postcss = require('gulp-postcss'),
rgba = require('postcss-hexrgba'),
autoprefixer = require('autoprefixer'),
cssvars = require('postcss-simple-vars'),
nested = require('postcss-nested'),
cssImport = require('postcss-import'),
mixins = require('postcss-mixins'),
colorFunctions = require('postcss-color-function');
gulp.task('styles', function() {
return gulp.src(settings.themeLocation + 'css/style.css')
.pipe(postcss([cssImport, mixins, cssvars, nested, rgba, colorFunctions, autoprefixer]))
.on('error', (error) => console.log(error.toString()))
.pipe(gulp.dest(settings.themeLocation));
});
gulp.task('scripts', function(callback) {
webpack(require('./webpack.config.js'), function(err, stats) {
if (err) {
console.log(err.toString());
}
console.log(stats.toString());
callback();
});
});
gulp.task('watch', function() {
browserSync.init({
notify: false,
proxy: settings.urlToPreview,
ghostMode: false
});
gulp.watch('./**/*.php', function(cb) {
browserSync.reload();
cb()
});
gulp.watch(settings.themeLocation + 'css/**/*.css', gulp.parallel('waitForStyles'));
gulp.watch([settings.themeLocation + 'js/src/js/blocks/*.js', settings.themeLocation + 'js/scripts.js'], gulp.parallel('waitForScripts'));
});
gulp.task('waitForStyles', gulp.series('styles', function() {
return gulp.src(settings.themeLocation + 'style.css')
.pipe(browserSync.stream()).pipe(browserSync.reload());
}))
gulp.task('waitForScripts', gulp.series('scripts', function(cb) {
browserSync.reload();
cb()
}))
Webpack config
const path = require('path'),
settings = require('./settings');
module.exports = {
entry: {
App: settings.themeLocation + "js/scritps.js"
},
output: {
path: path.resolve(__dirname, settings.themeLocation + "js"),
filename: "frontstreet.js"
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
},
mode: 'development'
}
файл настроек
exports.themeLocation = './wp-content/themes/front-theme/';
exports.urlToPreview = 'http://localhost:8888/front/';
это мои Wordpress functions.php
// add frontstreet pre-built
wp_enqueue_script('frontstreet-js', get_theme_file_uri('/js/frontstreet.js'), NULL, '1.0', true);