Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash #356

Merged
merged 2 commits into from
Aug 7, 2017
Merged

Hash #356

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"fs-extra": "^3.0.1",
"glob": "^7.1.2",
"gzip-size": "^3.0.0",
"html-webpack-plugin": "^2.30.1",
"http-proxy-middleware": "^0.17.3",
"is-plain-object": "^2.0.3",
"istanbul": "^0.4.5",
Expand Down
10 changes: 9 additions & 1 deletion src/config/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { existsSync } from 'fs';
import { join } from 'path';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import normalizeDefine from '../utils/normalizeDefine';
import winPath from '../utils/winPath';

Expand Down Expand Up @@ -65,7 +66,7 @@ export function getFirstRules({ paths, babelOptions }) {
return [
{
exclude: [
/\.html$/,
/\.(html|ejs)$/,
/\.(js|jsx)$/,
/\.(css|less|scss)$/,
/\.json$/,
Expand Down Expand Up @@ -289,6 +290,13 @@ export function getCommonPlugins({ config, paths, appBuild, NODE_ENV }) {
}
ret.push(new webpack.DefinePlugin(defineObj));

if (existsSync(join(paths.appSrc, 'index.ejs'))) {
ret.push(new HtmlWebpackPlugin({
template: 'src/index.ejs',
inject: true,
}));
}

if (existsSync(paths.appPublic)) {
ret.push(new CopyWebpackPlugin([
{
Expand Down
6 changes: 6 additions & 0 deletions src/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ export default function (args, appBuild, config, paths) {
chunkFilename: '[name].async.js',
};

// Support hash
if (config.hash) {
output.filename = '[name].[chunkhash].js';
output.chunkFilename = '[name].[chunkhash].async.js';
}

if (library) output.library = library;

const finalWebpackConfig = {
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/build/html-webpack-plugin/.roadhogrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"devtool": ""
}
1 change: 1 addition & 0 deletions test/fixtures/build/html-webpack-plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
13 changes: 13 additions & 0 deletions test/fixtures/build/html-webpack-plugin/src/index.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>

</body>
</html>
1 change: 1 addition & 0 deletions test/fixtures/build/html-webpack-plugin/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alert(1);