css - CSS 直接后代在生产构建中无法正常工作
问题描述
我怀疑这是 webpack 的问题,但我似乎无法让它工作。我唯一的 CSS 文件(main.css)包含以下代码:
.numpad > input {
text-align: center;
border: 2px solid blue;
margin: auto;
}
但是,当我发布应用程序时,CSS 文件显示以下内容:
.numpad {
text-align: center;
border: 2px solid blue;
margin: auto;
}
.numpad > input {
text-align: center;
border: 2px solid blue;
margin: auto;
}
我已经在整个解决方案中搜索了可能导致第一个重复项的任何类型的重复项。它不存在。我的 webpack 配置如下:
module.exports = (env) => {
const isDevBuild = !(env && env.prod);
return [{
stats: { modules: false },
entry: { 'main': './ClientApp/boot.tsx' },
resolve: { extensions: ['.js', '.jsx', '.ts', '.tsx'] },
output: {
path: path.join(__dirname, bundleOutputDir),
filename: '[name].js',
publicPath: 'dist/'
},
devtool: 'inline-source-map',
module: {
rules: [
{ test: /\.tsx?$/, include: /ClientApp/, use: 'awesome-typescript-loader?silent=true' },
{ test: /\.css$/, use: isDevBuild ? ['style-loader', 'css-loader'] : ExtractTextPlugin.extract({ use: 'css-loader?minimize' }) },
{ test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' },
{ test: /\.js$/, include: /src/, exclude: /node_modules/, use: { loader: "babel-loader", options: { presets: ['env'] } } }
]
},
plugins: [
new CheckerPlugin(),
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./wwwroot/dist/vendor-manifest.json')
}),
new CleanWebpackPlugin(['dist'])
].concat(isDevBuild ? [
// Plugins that apply in development builds only
new webpack.SourceMapDevToolPlugin({
filename: '[file].map', // Remove this line if you prefer inline source maps
moduleFilenameTemplate: path.relative(bundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk
})
] : [
// Plugins that apply in production builds only
new webpack.optimize.UglifyJsPlugin(),
new ExtractTextPlugin('main.css')
])
}];
};
关于为什么要创建副本的任何想法?
解决方案
推荐阅读
- esp8266 - 无需 SDK 的 ESP8266 编程
- ruby - 在 selenium ruby 中用 shift-enter 替换换行符
- shell - 完全限定的参数破坏了我的可执行文件
- python - Pythonic计算平均值的方法
- javascript - 在 javascript 中通过 DOM 获取“必需”的 div 元素
- ruby - S3 为不存在的项目创建签名 URL
- ecmascript-6 - lodash 按具有对象数组的属性对对象数组进行排序
- jquery - 触发航点时的多个动画
- testing - 使用 serialCorrelationTest() 对与 Ties 的自相关进行秩 von Neumann 检验
- r - 如何更改 rmdtemplate 材质主题中的颜色?