Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e5e74a6

Browse files
committed
add public folder to contain static assets
1 parent baed044 commit e5e74a6

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
node_modules
2-
public
2+
public/
33
build

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"babel-core": "^6.2.1",
2929
"babel-loader": "^6.2.0",
3030
"babel-preset-es2015": "^6.1.18",
31+
"copy-webpack-plugin": "^1.1.1",
3132
"css-loader": "^0.23.0",
3233
"extract-text-webpack-plugin": "^1.0.1",
3334
"file-loader": "^0.8.4",

src/public/img/favicon.ico

5.3 KB
Binary file not shown.

src/index.html renamed to src/public/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<head>
44
<meta charset="UTF-8">
55
<title>Angular App</title>
6+
<link rel="icon" type="image/x-icon" href="/img/favicon.ico">
7+
68
<base href="/">
79
</head>
810
<body>

webpack.config.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var webpack = require('webpack');
55
var autoprefixer = require('autoprefixer');
66
var HtmlWebpackPlugin = require('html-webpack-plugin');
77
var ExtractTextPlugin = require('extract-text-webpack-plugin');
8+
var CopyWebpackPlugin = require('copy-webpack-plugin');
89

910
module.exports = function makeWebpackConfig (ENV) {
1011
/**
@@ -149,9 +150,10 @@ module.exports = function makeWebpackConfig (ENV) {
149150
// Render index.html
150151
config.plugins.push(
151152
new HtmlWebpackPlugin({
152-
template: './src/index.html',
153+
template: './src/public/index.html',
153154
inject: 'body'
154155
}),
156+
155157
// Reference: https://github.com/webpack/extract-text-webpack-plugin
156158
// Extract css files
157159
// Disabled when in test mode or not in build mode
@@ -172,7 +174,13 @@ module.exports = function makeWebpackConfig (ENV) {
172174

173175
// Reference: http://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
174176
// Minify all javascript, switch loaders to minimizing mode
175-
new webpack.optimize.UglifyJsPlugin()
177+
new webpack.optimize.UglifyJsPlugin(),
178+
179+
// Copy assets from the public folder
180+
// Reference: https://github.com/kevlened/copy-webpack-plugin
181+
new CopyWebpackPlugin([{
182+
from: __dirname + '/src/public'
183+
}])
176184
)
177185
}
178186

@@ -182,7 +190,7 @@ module.exports = function makeWebpackConfig (ENV) {
182190
* Reference: http://webpack.github.io/docs/webpack-dev-server.html
183191
*/
184192
config.devServer = {
185-
contentBase: './public',
193+
contentBase: './src/public',
186194
stats: {
187195
modules: false,
188196
cached: false,

0 commit comments

Comments
 (0)