Skip to content

Commit 0a41404

Browse files
author
Bernie Zang
committed
fix(tooling): Add html build step, version to file header, global use strict
1 parent 5484fbb commit 0a41404

File tree

5 files changed

+133
-114
lines changed

5 files changed

+133
-114
lines changed

.babelrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"plugins": [
3-
["transform-runtime", { "polyfill": false }],
3+
["transform-runtime", {
4+
"polyfill": false
5+
}],
46
"transform-export-extensions",
57
"lodash"
68
],

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
"style-loader": "^0.13.1",
104104
"stylelint": "^7.7.1",
105105
"stylelint-config-standard": "^15.0.1",
106-
"webpack": "^2.2.0-rc.3",
107-
"webpack-dev-server": "^2.2.0-rc.0"
106+
"webpack": "^2.2.0",
107+
"webpack-dev-server": "^2.2.0"
108108
}
109109
}

packages/node_modules/@ciscospark/react-redux-spark/src/fixtures/spark.js

Lines changed: 104 additions & 105 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/webpack/webpack.base.babel.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@ import path from 'path';
22
import webpack from 'webpack';
33
import ExtractTextPlugin from 'extract-text-webpack-plugin';
44
import InlineEnviromentVariablesPlugin from 'inline-environment-variables-webpack-plugin';
5-
65
import dotenv from 'dotenv';
76

87
dotenv.config();
98

109
export default (options) => {
10+
const packageJson = require(`../../package.json`);
1111
const plugins = [
1212
new InlineEnviromentVariablesPlugin(Object.assign(process.env, options.env)),
1313
new ExtractTextPlugin({filename: `[name].css`, disable: false, allChunks: true}),
14-
new webpack.DefinePlugin({
15-
'process.env': {
16-
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
17-
}
18-
})
14+
// Adds use strict to prevent catch global namespace issues outside of chunks.
15+
new webpack.BannerPlugin(`react-ciscospark v${packageJson.version}`)
1916
];
2017

2118
return {

scripts/webpack/webpack.prod.babel.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
/**
22
* Webpack config for building individual packages for distribution
33
*/
4+
/* eslint no-sync:0 */
45

56
import path from 'path';
67
import webpack from 'webpack';
8+
import fs from 'fs';
9+
import HtmlWebpackPlugin from 'html-webpack-plugin';
710

811
import webpackBaseConfig from './webpack.base.babel';
912

@@ -18,6 +21,24 @@ const plugins = [
1821
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
1922
];
2023

24+
// Only create html file when one exists in src/
25+
if (fs.existsSync(`./src/index.html`)) {
26+
plugins.push(
27+
new HtmlWebpackPlugin({
28+
hash: true,
29+
minify: {
30+
collapseWhitespace: false,
31+
removeComments: true,
32+
removeScriptTypeAttributes: true,
33+
removeStyleLinkTypeAttributes: true,
34+
sortAttributes: true,
35+
sortClassName: true
36+
},
37+
template: `./index.html`
38+
})
39+
);
40+
}
41+
2142
export default webpackBaseConfig({
2243
entry: `./index.js`,
2344
output: {

0 commit comments

Comments
 (0)