- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
基本上我在 react-router 文件中有一个动态入口 block 。但是在 webpack 3
中,我无法从这些入口文件中将 css 提取到单独的 block 中。所以在 webpack 条目中包含相同的 block 名。
现在创建了 block 并提取了没有重复项的 css,并将来自多个条目文件的公共(public) scss 导入移动到 commonChunks 条目但我开始收到此错误。可能是因为我现在指定了两次入口 block (一次在 webpack 入口中,另一次在 react-router 文件中)
所以我升级到 3.10
它解决了问题,但现在 css block 中有重复的 css。
所以想知道在 webpack 3.2
中的单独命名 block 中提取 css 或解决 3.10
ERROR(仅在生产模式下出现)
manifest.a9c406e9412da8263008.js:1 未捕获类型错误:无法读取未定义的属性“调用”
在 n ( list .a9c406e9412da8263008.js:1)
在 Object../desktop-containers/Index/index.js (VM150 home.1ee4964ea9da62fee1c0.js:1)
在 n ( list .a9c406e9412da8263008.js:1)
在 window.webpackJsonp( list .a9c406e9412da8263008.js:1)
在 VM150 home.1ee4964ea9da62fee1c0.js:1
链接到github问题 https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/185#issuecomment-419396442
/* Desktop webpack client-side config */
const webpack = require('webpack');
const path = require('path');
const DashboardPlugin = require('webpack-dashboard/plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
const autoprefixer = require('autoprefixer');
const WebpackStableModuleIdAndHash = require('webpack-stable-module-id-and-hash');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const AssetsPlugin = require('assets-webpack-plugin');
const HashOutput = require('webpack-plugin-hash-output');
const nodeEnv = process.env.NODE_ENV;
const isProduction = nodeEnv === 'production';
/** ***********common rules********* */
const rules = [
{
test: /\.html$/,
loader: 'html-loader'
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader'
}
]
}
];
const plugins = [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(nodeEnv)
},
__BROWSER__: true
}),
new webpack.NamedModulesPlugin(), // used for scope hoisting in webpack 3
new webpack.LoaderOptionsPlugin({
options: {
postcss: [
autoprefixer({
browsers: ['> 1%', 'Firefox >= 20', 'ie >= 9']
})
],
context: path.resolve(`${__dirname}client`)
}
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'main',
children: true,
minChunks: 2
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
minChunks: Infinity
}),
// optimize moment
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
// exclude mobile-specific modules
new webpack.IgnorePlugin(/react-input-range/),
new webpack.IgnorePlugin(/react-lazy-load/),
new webpack.IgnorePlugin(/react-collapse/),
new webpack.IgnorePlugin(/react-motion/),
new webpack.IgnorePlugin(/react-scroll/)
];
/** *********end********** */
/** **********rules for non production***** */
if (!isProduction) {
rules.push({
test: /\.scss$/,
exclude: /node_modules/,
use: [
'style-loader',
// Using source maps breaks urls in the CSS loader
// https://github.com/webpack/css-loader/issues/232
// This comment solves it, but breaks testing from a local network
// https://github.com/webpack/css-loader/issues/232#issuecomment-240449998
// 'css-loader?sourceMap',
'css-loader',
'postcss-loader',
'sass-loader',
{
loader: 'stylefmt-loader',
options: {
config: '.stylelintrc'
}
}
]
});
plugins.push(
new webpack.HotModuleReplacementPlugin(),
new BundleAnalyzerPlugin({
analyzerPort: 9999
})
);
}
/** *********end******** */
/** ** only for proudction rule starts ****** */
if (isProduction) {
rules.push({
test: /\.scss$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader!postcss-loader!sass-loader'
})
});
plugins.push(
new ExtractTextPlugin({
filename: '[name].[contentHash].css',
allChunks: true
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}),
new webpack.optimize.UglifyJsPlugin(),
new HashOutput(), // used for MD5 hashing of assets
new WebpackStableModuleIdAndHash(),
new AssetsPlugin({
filename: 'assetsManifestDesktop.json',
path: path.resolve('./build'),
prettyPrint: true
})
);
}
/** **************end *********** */
module.exports = {
devtool: isProduction ? false : 'source-map',
context: path.join(`${__dirname}/client`),
entry: {
main: 'app-desktop.js',
home: 'desktop-containers/Index',
wizardLandingPage: 'common-containers/WizardLandingPage',
auth: 'desktop-containers/Auth',
vendor: [
'babel-polyfill',
'fingerprint',
'isomorphic-fetch',
'moment',
'moment-range',
'react',
'react-addons-css-transition-group',
'react-cookie',
'react-daterange-picker',
'react-dom',
'react-helmet',
'react-redux',
'react-router',
'react-waypoint',
'redux',
'redux-thunk'
]
},
output: {
path: isProduction ? path.join(`${__dirname}/build/desktop`) : path.join(`${__dirname}/dist/desktop`), // webpack cli output directory
publicPath: '/assets/desktop/', // from where actually assets will be served.
filename: isProduction ? '[name].[chunkhash].js' : '[name].js',
chunkFilename: isProduction ? '[name].[chunkhash].js' : '[name].js'
},
module: {
rules
},
performance: isProduction && {
maxAssetSize: 100,
maxEntrypointSize: 300,
hints: 'warning'
},
resolve: {
alias: {
react: 'preact-compat',
'react-dom': 'preact-compat',
'create-react-class': 'preact-compat/lib/create-react-class',
components: path.resolve(__dirname, 'client/desktop-components')
},
extensions: ['dev-server.js', '.webpack-loader.js', '.web-loader.js', '.loader.js', '.js', '.jsx'],
modules: [path.join(`${__dirname}/client`), path.join(`${__dirname}/node_modules`)]
},
plugins,
devServer: {
contentBase: './dist/desktop',
historyApiFallback: {
index: 'index.html'
},
port: 7000,
compress: isProduction,
inline: !isProduction,
hot: !isProduction,
disableHostCheck: true,
host: '0.0.0.0'
}
};
最佳答案
以下两种可能的解决方案可能有助于解决问题。
如果您正在使用,请在您的 webpack.config.js 中删除 DedupePlugin
//new webpack.optimize.DedupePlugin()
或
通过添加 allChunks: true 修复它:
new ExtractTextPlugin({
filename: cssFileName,
allChunks: true
})
或
在您的 Webpack 配置中导入以下两个
require('style-loader/lib/addStyles');
require('css-loader/lib/css-base');
查看此 github issue 和 github issue1 了解更多详情
关于javascript - Webpack 未捕获类型错误 : Cannot read property 'call' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52220666/
我正在尝试编写一个相当多态的库。我遇到了一种更容易表现出来却很难说出来的情况。它看起来有点像这样: {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE
谁能解释一下这个表达式是如何工作的? type = type || 'any'; 这是否意味着如果类型未定义则使用“任意”? 最佳答案 如果 type 为“falsy”(即 false,或 undef
我有一个界面,在IAnimal.fs中, namespace Kingdom type IAnimal = abstract member Eat : Food -> unit 以及另一个成功
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: What is the difference between (type)value and type(va
在 C# 中,default(Nullable) 之间有区别吗? (或 default(long?) )和 default(long) ? Long只是一个例子,它可以是任何其他struct类型。 最
假设我有一个案例类: case class Foo(num: Int, str: String, bool: Boolean) 现在我还有一个简单的包装器: sealed trait Wrapper[
这个问题在这里已经有了答案: Create C# delegate type with ref parameter at runtime (1 个回答) 关闭 2 年前。 为了即时创建委托(dele
我正在尝试获取图像的 dct。一开始我遇到了错误 The function/feature is not implemented (Odd-size DCT's are not implemented
我正在尝试使用 AFNetworking 的 AFPropertyListRequestOperation,但是当我尝试下载它时,出现错误 预期的内容类型{( “应用程序/x-plist” )}, 得
我在下面收到错误。我知道这段代码的意思,但我不知道界面应该是什么样子: Element implicitly has an 'any' type because index expression is
我尝试将 SignalType 从 ReactiveCocoa 扩展为自定义 ErrorType,代码如下所示 enum MyError: ErrorType { // .. cases }
我无法在任何其他问题中找到答案。假设我有一个抽象父类(super class) Abstract0,它有两个子类 Concrete1 和 Concrete1。我希望能够在 Abstract0 中定义类
我想知道为什么这个索引没有用在 RANGE 类型中,而是用在 INDEX 中: 索引: CREATE INDEX myindex ON orders(order_date); 查询: EXPLAIN
我正在使用 RxJava,现在我尝试通过提供 lambda 来订阅可观察对象: observableProvider.stringForKey(CURRENT_DELETED_ID) .sub
我已经尝试了几乎所有解决问题的方法,其中包括。为 提供类型使用app.use(express.static('public'))还有更多,但我似乎无法为此找到解决方案。 index.js : imp
以下哪个 CSS 选择器更快? input[type="submit"] { /* styles */ } 或 [type="submit"] { /* styles */ } 只是好
我不知道这个设置有什么问题,我在 IDEA 中获得了所有注释(@Controller、@Repository、@Service),它在行号左侧显示 bean,然后转到该 bean。 这是错误: 14-
我听从了建议 registering java function as a callback in C function并且可以使用“简单”类型(例如整数和字符串)进行回调,例如: jstring j
有一些 java 类,加载到 Oracle 数据库(版本 11g)和 pl/sql 函数包装器: create or replace function getDataFromJava( in_uLis
我已经从 David Walsh 的 css 动画回调中获取代码并将其修改为 TypeScript。但是,我收到一个错误,我不知道为什么: interface IBrowserPrefix { [
我是一名优秀的程序员,十分优秀!