- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我 web pack 的时候
--watch --config webpack.production.config.js --mode production
我有这个错误:
ERROR in TypeError: cb is not a function
index.js:160 compilation.plugin [formation-front]/[preload-webpack-plugin]/index.js:160:9
new Promise
Hook.js:35 AsyncSeriesWaterfallHook.lazyCompileHook [as _promise] [formation-front]/[tapable]/lib/Hook.js:35:21
index.js:673 [formation-front]/[html-webpack-plugin]/index.js:673:47
index.js:178 Promise.resolve.then.then.then.then.then.then.html [formation-front]/[html-webpack-plugin]/index.js:178:18
这是我的 webpack.production.config.js :
'use strict';
// process.traceDeprecation = true
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const PreloadWebpackPlugin = require('preload-webpack-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');
const path = require('path');
const webpack = require('webpack');
const CompressionPlugin = require('compression-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const entry = {
app: [
'babel-polyfill',
path.resolve(__dirname, './client/app/app.js')
]
};
const output = {
filename: '[name].[chunkhash].js',
path: path.resolve(__dirname, 'dist'),
publicPath: ''
};
const uglifyOptions = {
cache: true,
parallel: true,
uglifyOptions: {
ie8: false,
ecma: 8,
compress: {
conditionals: true,
unused: true,
comparisons: true,
sequences: true,
dead_code: true,
evaluate: true,
if_return: true,
join_vars: true
},
output: {
comments: false,
beautify: false
},
mangle: {
reserved: ['$super', '$', 'exports', 'require', 'angular']
},
warnings: false
}
};
const modules = {
rules: [
{
test: /\.js$/,
exclude: [/node_modules/, /app\/assets/],
use: [
{
loader: 'ng-annotate-loader'
},
{
loader: 'babel-loader'
}
]
},
{
test: /\.html$/,
use: [{
loader: 'raw-loader'
}]
},
{
test: /\.(sass|scss)$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{
loader: "css-loader"
},
{
loader: "sass-loader"
}
]
})
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{
loader: "css-loader"
},
{
loader: "sass-loader"
}
]
})
},
{
test: /\.(gif|png|jpe?g|svg)$/i,
use: [
{
loader: 'file-loader',
options: {
hash: 'sha512',
digest: 'hex',
name: '[hash].[ext]'
}
},
{
loader: 'image-webpack-loader',
options: {
query: {
mozjpeg: {
progressive: true
},
optipng: {
optimizationLevel: 7
},
gifsicle: {
interlaced: 'true'
},
pngquant: {
quality: '65-90',
speed: '4'
}
}
}
}
]
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [{
loader: 'url-loader',
options: {
limit: '10000',
mimetype: 'application/font-woff'
}
}]
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [{
loader: 'file-loader',
}]
},
]
};
const plugins = [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production')
}),
new webpack.HashedModuleIdsPlugin(),
new HtmlWebpackPlugin({
hash: true,
inject: true,
template: 'client/index.html',
minify: {
collapseWhitespace: true,
collapseInlineTagWhitespace: true,
removeComments: true,
removeRedundantAttributes: true
}
}),
new PreloadWebpackPlugin({
rel: 'preload',
as: 'script',
include: 'all',
fileBlacklist: [/\.(css|map)$/, /client?.+/]
}),
new ScriptExtHtmlWebpackPlugin({
defaultAttribute: 'defer'
}),
new HtmlWebpackInlineSourcePlugin(),
new CompressionPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: /\.js$|\.css$|\.html$|\.eot?.+$|\.ttf?.+$|\.woff?.+$|\.svg?.+$/,
threshold: 10240,
minRatio: 0.8
}),
new ExtractTextPlugin({
disable: true,
filename: "[name].[contenthash].css"
}),
];
try {
module.exports = {
mode: 'production',
devtool: '',
entry,
output,
module: modules, // Set to not conflict with module from module.exports,
plugins,
optimization: {
namedModules: true, // NamedModulesPlugin()
splitChunks: { // CommonsChunkPlugin()
name: 'vendor',
filename: 'vendor.[chunkhash].js',
minChunks: 2,
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all'
}
}
},
minimizer: [
new UglifyJsPlugin(uglifyOptions)
],
concatenateModules: true // ModuleConcatenationPlugin
}
};
} catch (err) {
console.log(err);
}
这是我的 package.json :
{
"name": "Argalis",
"version": "0.0.1",
"description": "-",
"main": "index.js",
"dependencies": {
"@uirouter/angularjs": "^1.0.18",
"angular": "^1.7.2",
"angular-clock": "^0.7.0",
"angular-file-saver": "^1.1.3",
"angular-perfect-scrollbar-2": "^1.2.5",
"angular-recaptcha": "^4.1.5",
"angular-upload": "^1.0.13",
"b64-to-blob": "^1.2.19",
"babel-preset-es2015": "^6.24.1",
"babel-register": "^6.23.0",
"config": "^1.29.4",
"font-awesome": "^4.7.0",
"jquery": "^3.3.1",
"json-loader": "^0.5.4",
"leaflet": "^1.3.1",
"leaflet-routing-machine": "^3.2.8",
"less": "^3.0.4",
"lodash": "^4.17.10",
"materialize-css": "^0.100.2",
"moment": "^2.22.2",
"moment-timezone": "^0.5.21",
"node-sass": "^4.9.0",
"node-uuid": "^1.4.7",
"postcss-loader": "^2.1.5",
"required-loader": "^1.3.16",
"uid-safe": "^2.1.3",
"underscore": "^1.9.1",
"webpack-file-preprocessor-plugin": "0.0.1",
"yarn-upgrade-all": "^0.3.0"
},
"devDependencies": {
"angular-jwt": "^0.1.10",
"angular-materialize": "^0.2.1",
"angular-mocks": "^1.7.2",
"angular-remove-di-loaders": "^1.0.4",
"autoprefixer": "^8.6.3",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.5",
"babel-loader": "^7.1.4",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-async-to-generator": "^6.16.0",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-polyfill": "^6.7.4",
"babel-preset-env": "^1.7.0",
"babel-runtime": "^6.6.1",
"browser-sync": "^2.24.5",
"chai": "^4.1.2",
"compression-webpack-plugin": "^1.1.6",
"connect-history-api-fallback": "^1.1.0",
"css-loader": "^0.28.11",
"eslint": "^5.0.1",
"eslint-config-airbnb": "^17.0.0",
"eslint-config-angular": "^0.5.0",
"eslint-loader": "^2.0.0",
"eslint-plugin-angular": "^3.3.0",
"eslint-plugin-async": "^0.1.1",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.10.0",
"extract-text-webpack-plugin": "^4.0.0-alpha.0",
"file-loader": "^1.1.11",
"font-awesome-webpack": "0.0.5-beta.2",
"fs-walk": "0.0.2",
"gulp": "^4.0.0",
"gulp-rename": "^1.3.0",
"gulp-template": "^5.0.0",
"gulp-util": "^3.0.7",
"html-webpack-inline-source-plugin": "^0.0.10",
"html-webpack-plugin": "^3.2.0",
"htmlhint-loader": "^1.3.1",
"image-webpack-loader": "^4.3.1",
"imports-loader": "^0.8.0",
"karma": "^2.0.4",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.0.0",
"karma-mocha": "^1.1.1",
"karma-mocha-reporter": "^2.2.0",
"karma-sourcemap-loader": "^0.3.4",
"karma-webpack": "^3.0.0",
"mocha": "^5.2.0",
"ng-annotate-loader": "0.6.1",
"node-libs-browser": "^2.1.0",
"preload-webpack-plugin": "^2.3.0",
"preprocess": "^3.1.0",
"raw-loader": "^0.5.1",
"run-sequence": "^2.2.1",
"sass-lint": "^1.7.0",
"sass-loader": "^7.0.3",
"sasslint-webpack-plugin": "^1.0.3",
"script-ext-html-webpack-plugin": "^2.0.1",
"style-loader": "^0.21.0",
"supports-color": "^5.4.0",
"uid": "0.0.2",
"url-loader": "^1.0.1",
"webpack": "^4.12.1",
"webpack-bundle-analyzer": "^2.13.1",
"webpack-cli": "^3.0.8",
"webpack-dev-server": "^3.1.4",
"yargs": "^11.0.0",
"zxcvbn": "^4.4.0"
},
"scripts": {
"test": "return 0",
"serve": "set NODE_ENV=development&&gulp serve",
"start": "webpack --watch --config webpack.dev.config.js --mode development",
"start-ifrac": "set NODE_ENV=dev_ifrac && npm start",
"build": "webpack --bail --config --mode production webpack.production.config.js",
"build-ifrac": "set NODE_ENV=prod_ifrac && webpack --bail --mode production --config webpack.prod_ifrac.config.js",
"build-socotec": "set NODE_ENV=prod_socotec && webpack --bail --mode production --config webpack.prod_socotec.config.js",
"buildtest": "webpack --config --bail --mode production webpack.test.config.js"
},
"keywords": [
"angular",
"webpack",
"es6"
],
"repository": {
"type": "git",
"url": "https://gitlab.com/Argalis/formation-front.git"
},
"author": "Argalis"
}
最佳答案
我认为还不支持 webpack v4。有一个 PR 添加 https://github.com/GoogleChromeLabs/preload-webpack-plugin/pull/72
关于webpack - Preload Webpack 插件和 Webpack 4 出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51063453/
我遇到的“预加载”的唯一设置是“无” - 有哪些选择? 我有一部很长的电影,需要一段时间才能开始(我假设是因为大小),我希望能够让它更快地播放。我认为让视频在页面加载后立即开始加载会给观众一个更快的
我正在为 PWA 开发一个 gatsby 主题/启动器,但我似乎无法摆脱以下控制台警告: The resource https://davidde.github.io/gatsby-starter-s
我正在使用 使资源加载速度更快的技术,但我没有看到对页面加载时间的可衡量影响。我不确定这是因为资源实际上没有被预加载,还是因为其他原因。 如果我使用 Firefox 进行调试,如何在 Firefox
如何正确预加载谷歌字体,而不在控制台中发出警告? 这是我的代码: 我已经在预加载链接中添加了 crossorigin 属性,但警告仍然存在 最佳答案 只需将跨域属性添加到主样式表
我正在从头开始学习 webpack。我已经学会了如何将 javascript 文件与 require 链接起来。我正在捆绑和缩小我的 js 文件,我正在用 watch 监听变化。我正在设置加载程序以将
我的 Rails 3.2 应用程序使用两个不同的数据库。主操作系统是 MySQL,而其他操作系统是 sqlserver 数据库: development: adapter: mysql2
我的响应式 flexslider 插件有问题。除非您在实际幻灯片中有许多图像,否则该插件可以正常工作。加载行为是 Not Acceptable 。 我希望有人可以帮助我使用以下 flexslider
我正在尝试修改页面上的控件以减少 session 依赖性。我目前无法访问页面本身,只能访问主要由 DataGrid 组成的控件。我正在尝试在回发时检索 DataGrid 信息,以便我可以操作数据并重新
我发现该指令在 Controls.pas(以及其他单元)中声明,我很高兴知道它的含义。 {$C PRELOAD} 据我所知 $C 表示断言控制,但是 PRELOAD 关键字是什么?是不是类似于“在预加
为了在加载远程内容时提供适当的安全级别,声明必须分别启用和禁用BrowserWindow的contextIsolation和nodeIntegration选项。在这种情况下,Node/Electron
为什么 Gorm 中的 Preload 函数是一个“好的实践”,因为每次调用它时它都会检索给定表的所有记录(热切加载)? 我看到很多人在处理关系时将预加载视为一个很好的解决方案,但我不明白为什么。 最
我已经安装了webpack@2.1.0-beta.27。之前,我使用的是 webpack@2.1.0-beta.22。在我的配置文件中,我使用了 preLoaders 和 postLoaders: p
我有代码: jQuery(img).each(function() { jQuery(this).animate({opacity: 0}); jQuery(t
这是 JPA2 实体监听器注释: @PrePersist @PreRemove @PostPersist @PostRemove @PreUpdate @PostUpdate @PostLoad 但是
Android MapView.preLoad() 方法的真正作用是什么? “API 声明在 map 当前中心预加载图 block ”。这是什么意思,我能否以某种方式使用它来加快 map 在我的 Ma
我正在开发一个 JavaFX 应用程序,该应用程序需要在启动主应用程序阶段之前从文件中加载资源。我完成此任务的解决方案是使用 PreLoader,以便用户在加载资源之前无法与应用程序交互(非常标准的东
好的,首先,这是我的代码。 var loader = document.getElementById("loader"); window.addEventListener("loader", func
在 CSS 中,我为转换编写了一些肮脏的代码,它加载了 24 个不同的蒙版图像。第一次播放时,加载时有延迟,但如果我有一个 div“预加载”它,即在页面加载时播放它,它似乎被缓存了,因此不会再次延迟,
我正在为我的网站制作一个自定义预加载器。它在本地主机上运行良好,但在实时站点上,div 不显示动画,文本仅放置在站点底部。
我使用 CSS 创建了一个预加载器。我想在预加载器完成后在幻灯片放映中显示图像。预加载完成后,图像应该会平滑淡入。这是我的代码结构。 #container{
我是一名优秀的程序员,十分优秀!