Skip to content

Commit

Permalink
解决冲突
Browse files Browse the repository at this point in the history
  • Loading branch information
杨斌 committed Sep 8, 2017
2 parents d3e7e17 + 39c377e commit 1288853
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.1.0",
"html-webpack-plugin": "^2.29.0",
"html-webpack-template": "^5.6.0",
"redbox-react": "^1.2.10",
"roadhog": "^1.2.2"
},
Expand Down
25 changes: 25 additions & 0 deletions src/entry.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<% htmlWebpackPlugin.options.headScripts = htmlWebpackPlugin.options.headScripts || [] %>
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="A admin dashboard application demo built upon Ant Design and Dva.js">
<title>antd admin</title>
<!--[if lte IE 10]>
<script
src="https://as.alipayobjects.com/g/component/??console-polyfill/0.2.2/index.js,media-match/2.0.2/media.match.min.js"></script>
<![endif]-->
<% for (item of htmlWebpackPlugin.options.headScripts) { %>
<script src="<%= item %>"></script>
<% } %>
</head>

<body>
<div id="root"></div>
</body>


</html>
28 changes: 7 additions & 21 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
const HtmlWebpackPlugin = require('html-webpack-plugin')
const HtmlWebpackTemplate = require('html-webpack-template')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const webpack = require('webpack')

module.exports = (webpackConfig, env) => {
const production = env === 'production'
// FilenameHash
webpackConfig.output.chunkFilename = '[name].[hash].js'
webpackConfig.output.chunkFilename = '[name].[chunkhash].js'

if (production) {
if (webpackConfig.module) {
// ClassnameHash
webpackConfig.module.rules.map((item) => {
if (String(item.test) === '/\\.less$/' || item.test === '/\\.css/') {
if (String(item.test) === '/\\.less$/' || String(item.test) === '/\\.css/') {
item.use.filter(iitem => iitem.loader === 'css')[0].options.localIdentName = '[hash:base64:5]'
}
return item
Expand All @@ -34,26 +33,13 @@ module.exports = (webpackConfig, env) => {
},
]),
new HtmlWebpackPlugin({
hash: true,
mobile: true,
title: 'antd-admin',
inject: false,
appMountId: 'root',
template: `!!ejs-loader!${HtmlWebpackTemplate}`,
template: `${__dirname}/src/entry.ejs`,
filename: production ? '../index.html' : 'index.html',
minify: {
minify: production ? {
collapseWhitespace: true,
},
scripts: production ? null : ['/roadhog.dll.js'],
meta: [
{
name: 'description',
content: 'A admin dashboard application demo built upon Ant Design and Dva.js',
}, {
name: 'viewport',
content: 'width=device-width, initial-scale=1.0',
},
],
} : null,
hash: true,
headScripts: production ? null : ['/roadhog.dll.js'],
}),
])

Expand Down

0 comments on commit 1288853

Please sign in to comment.