Answer the question
In order to leave comments, you need to log in
Why did webpack suddenly stop working?
For some reason I stopped compiling, yesterday everything was fine. Today suddenly began to swear at all css files. Writes this:
Child mini-css-extract-plugin node_modules/css-loader/dist/cjs.js??ref--8-2!node_modules/postcss-loader/src/index.js??ref--8-3!node_modules/less-loader/dist/cjs.js??ref--8-4!src/blocks/toggle/toggle.less:
Entrypoint mini-css-extract-plugin = *
[0] ./node_modules/css-loader/dist/cjs.js??ref--8-2!./node_modules/postcss-loader/src??ref--8-3!./node_modules/less-loader/dist/cjs.js??ref--8-4!./src/blocks/toggle/toggle.less 3.12 KiB {0} [built] [failed] [1 error]
ERROR in ./src/blocks/toggle/toggle.less (./node_modules/css-loader/dist/cjs.js??ref--8-2!./node_modules/postcss-loader/src??ref--8-3!./node_modules/less-loader/dist/cjs.js??ref--8-4!./src/blocks/toggle/toggle.less)
Module build failed (from ./node_modules/postcss-loader/src/index.js):
Error: Cannot find module './Tokenizer'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (/Users/nikita/Desktop/работа/FSD/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/Users/nikita/Desktop/работа/FSD/node_modules/css-tree/lib/tokenizer/index.js:1:80)
at Module._compile (/Users/nikita/Desktop/работа/FSD/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (/Users/nikita/Desktop/работа/FSD/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/Users/nikita/Desktop/работа/FSD/node_modules/css-tree/lib/lexer/generic.js:1:79)
at Module._compile (/Users/nikita/Desktop/работа/FSD/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (/Users/nikita/Desktop/работа/FSD/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/Users/nikita/Desktop/работа/FSD/node_modules/css-tree/lib/lexer/Lexer.js:4:15)
at Module._compile (/Users/nikita/Desktop/работа/FSD/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (/Users/nikita/Desktop/работа/FSD/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/Users/nikita/Desktop/работа/FSD/node_modules/css-tree/lib/syntax/create.js:4:13)
at Module._compile (/Users/nikita/Desktop/работа/FSD/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (/Users/nikita/Desktop/работа/FSD/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
const path = require('path')
const fs = require('fs')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
//const { VueLoaderPlugin } = require('vue-loader')
// Main const
// see more: https://github.com/vedees/webpack-template/blob/master/README.md#main-const
const PATHS = {
src: path.join(__dirname, '../src'),
dist: path.join(__dirname, '../dist'),
assets: 'assets/'
}
// Pages const for HtmlWebpackPlugin
// see more: https://github.com/vedees/webpack-template/blob/master/README.md#html-dir-folder
// const PAGES_DIR = PATHS.src
const PAGES_DIR = `${PATHS.src}/pages`
const PAGES = fs.readdirSync(PAGES_DIR).filter(fileName => fileName.endsWith('.pug'))
const PAGES_ENTRY = fs.readdirSync(PAGES_DIR).filter(fileName => fileName.endsWith('.js'))
module.exports = {
externals: {
paths: PATHS
},
entry: {
kit: `${PATHS.src}/pages/ui-kit.js`
},
output: {
filename: `${PATHS.assets}js/[name].js`,
path: PATHS.dist,
publicPath: '/'
},
module: {
rules: [{
test: /\.pug$/,
oneOf: [
{
use: ['pug-loader']
}
]
}, {
test: /\.js$/,
loader: 'babel-loader',
exclude: '/node_modules/'
}, {
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader',
options: {
outputPath: `${PATHS.assets}fonts`,
name: '[name].[ext]'
}
}, {
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
outputPath: `${PATHS.assets}img`,
name: '[name].[ext]'
}
}, {
test: /\.less$/,
use: [
'style-loader',
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
sourceMap: true,
url: false
}
}, {
loader: 'postcss-loader',
options: { sourceMap: true, config: { path: `./postcss.config.js` } }
}, {
loader: 'less-loader',
options: { sourceMap: true }
}
]
}, {
test: /\.css$/,
use: [
'style-loader',
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
sourceMap: true,
url: false
}
}, {
loader: 'postcss-loader',
options: { sourceMap: true, config: { path: `./postcss.config.js` } }
}
]
}]
},
resolve: {
alias: {
'~': PATHS.src+"/pages",
}
},
plugins: [
new MiniCssExtractPlugin({
filename: `${PATHS.assets}css/[name].css`,
}),
new CopyWebpackPlugin([
{ from: `${PATHS.src}/${PATHS.assets}img`, to: `${PATHS.assets}img` },
{ from: `${PATHS.src}/${PATHS.assets}fonts`, to: `${PATHS.assets}fonts` },
{ from: `${PATHS.src}/static`, to: 'static' },
]),
// Automatic creation any html pages (Don't forget to RERUN dev server)
// see more: https://github.com/vedees/webpack-template/blob/master/README.md#create-another-html-files
// best way to create pages: https://github.com/vedees/webpack-template/blob/master/README.md#third-method-best
...PAGES.map(page => new HtmlWebpackPlugin({
template: `${PAGES_DIR}/${page}`,
filename: `./${page.replace(/\.pug/,'.html')}`
}))
],
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question