Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

Commit bad74e7

Browse files
author
Tynarus
authored
Merge pull request #15 from Tynarus/global-stylesheet
fixing global css file and some prod build issues
2 parents 915848b + 907fd1a commit bad74e7

File tree

9 files changed

+58
-43
lines changed

9 files changed

+58
-43
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ A basic Angular 4 seed project utilizing the following technologies:
1515
* `npm test` - run the project unit tests (*.spec.ts files)
1616
* `npm run coverage` - run the project unit tests one time and print out a coverage report, generated under **/coverage/index.html**
1717
* `npm run lint` - run the project linting (will be run every time `npm test` is run)
18-
* `npm run build` - generate a production build for the project, which will be inserted into dist/
18+
* `npm run build` - generate a production build for the project, which will be inserted into dist/
19+
* `npm run server` - run a live-server instance off of the **dist/** directory (generated from the `build` command)

config/build/webpack.common.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
var webpack = require('webpack');
2-
var HtmlWebpackPlugin = require('html-webpack-plugin');
3-
var helpers = require('../helpers');
1+
const webpack = require('webpack');
2+
const HtmlWebpackPlugin = require('html-webpack-plugin');
3+
const helpers = require('../helpers');
4+
const ExtractTextPlugin = require('extract-text-webpack-plugin');
45

56
module.exports = {
67
entry: {
78
'polyfills': './src/polyfills.ts',
89
'vendor': './src/vendor.ts',
9-
'app': './src/main.ts'
10+
'app': './src/main.ts',
11+
'styles': './src/global.scss'
1012
},
1113

1214
resolve: {
@@ -28,20 +30,17 @@ module.exports = {
2830
{
2931
test: /\.scss$/,
3032
exclude: [ /node_modules/, helpers.root('src', 'global.scss') ],
31-
use: [ 'raw-loader', 'sass-loader' ]
33+
use: [ 'to-string-loader', 'css-loader', 'sass-loader' ]
3234
},
3335
{
34-
test: helpers.root('src', 'global.scss'),
35-
use: [ 'style-loader', 'css-loader', 'sass-loader' ]
36+
test: /global\.scss$/,
37+
use: ExtractTextPlugin.extract({
38+
use: 'css-loader!sass-loader'
39+
})
3640
},
3741
{
3842
test: /\.(png|jpe?g|gif|svg|woff|woff2|otf|ttf|eot|ico)$/,
3943
use: 'file-loader?name=assets/[name].[hash].[ext]'
40-
},
41-
{
42-
test: /\.css$/,
43-
exclude: helpers.root('src', 'app'),
44-
use: [ 'raw-loader', 'css-loader' ]
4544
}
4645
]
4746
},
@@ -57,7 +56,7 @@ module.exports = {
5756

5857
new webpack.ContextReplacementPlugin(
5958
/angular(\\|\/)core(\\|\/)@angular/,
60-
helpers.root('src'), // location of your src
59+
helpers.root('src'),
6160
{}
6261
)
6362
]

config/build/webpack.dev.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
var webpackMerge = require('webpack-merge');
2-
var commonConfig = require('./webpack.common.js');
3-
var helpers = require('../helpers');
1+
const webpackMerge = require('webpack-merge');
2+
const commonConfig = require('./webpack.common.js');
3+
const helpers = require('../helpers');
4+
const ExtractTextPlugin = require('extract-text-webpack-plugin');
45

56
module.exports = webpackMerge(commonConfig, {
67
devtool: 'cheap-module-eval-source-map',
@@ -23,5 +24,9 @@ module.exports = webpackMerge(commonConfig, {
2324
changeOrigin: true
2425
}
2526
}*/
26-
}
27+
},
28+
29+
plugins: [
30+
new ExtractTextPlugin('styles.css')
31+
]
2732
});

config/build/webpack.prod.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
var webpack = require("webpack");
2-
var webpackMerge = require("webpack-merge");
3-
var ExtractTextPlugin = require("extract-text-webpack-plugin");
4-
var commonConfig = require("./webpack.common.js");
5-
var helpers = require("../helpers");
1+
const webpack = require('webpack');
2+
const webpackMerge = require('webpack-merge');
3+
const commonConfig = require('./webpack.common.js');
4+
const helpers = require('../helpers');
5+
const ExtractTextPlugin = require('extract-text-webpack-plugin');
66

7-
const ENV = process.env.NODE_ENV = process.env.ENV = "production";
7+
const ENV = process.env.NODE_ENV = process.env.ENV = 'production';
88

99
module.exports = webpackMerge(commonConfig, {
10-
devtool: "source-map",
10+
devtool: 'source-map',
1111

1212
output: {
13-
path: helpers.root("dist"),
14-
publicPath: "/",
15-
filename: "[name].[hash].js",
16-
chunkFilename: "[id].[hash].chunk.js"
13+
path: helpers.root('dist'),
14+
publicPath: '/',
15+
filename: '[name].[hash].js',
16+
chunkFilename: '[id].[hash].chunk.js'
1717
},
1818

1919
plugins: [
@@ -23,10 +23,10 @@ module.exports = webpackMerge(commonConfig, {
2323
keep_fnames: true
2424
}
2525
}),
26-
new ExtractTextPlugin("[name].[hash].css"),
26+
new ExtractTextPlugin('styles.[hash].css'),
2727
new webpack.DefinePlugin({
28-
"process.env": {
29-
"ENV": JSON.stringify(ENV)
28+
'process.env': {
29+
'ENV': JSON.stringify(ENV)
3030
}
3131
}),
3232
new webpack.LoaderOptionsPlugin({

config/server/prod-server.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const liveServer = require("live-server");
2+
3+
const params = {
4+
port: 8181,
5+
root: 'dist',
6+
open: false,
7+
ignore: 'scss,my/templates',
8+
file: 'index.html',
9+
wait: 1000,
10+
logLevel: 2
11+
};
12+
13+
liveServer.start(params);

config/test/webpack.test.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@ module.exports = {
2222
{
2323
test: /\.scss$/,
2424
exclude: /node_modules/,
25-
use: [ 'raw-loader', 'sass-loader' ]
26-
},
27-
{
28-
test: /\.css$/,
29-
include: helpers.root('src', 'app'),
30-
use: 'raw-loader'
25+
use: [ 'to-string-loader', 'css-loader', 'sass-loader' ]
3126
}
3227
]
3328
},

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"coverage": "npm run lint && karma start config/test/karma.conf.js --coverage=true",
1414
"lint": "tslint -c config/tslint.json \"src/app/**/*.ts\"",
1515
"pretest": "npm run lint",
16-
"build": "rimraf dist && webpack --config config/build/webpack.prod.js --progress --profile --bail"
16+
"build": "rimraf dist && webpack --config config/build/webpack.prod.js --progress --profile --bail",
17+
"server": "node config/server/prod-server.js"
1718
},
1819
"dependencies": {
1920
"@angular/common": "^4.3.6",
@@ -37,6 +38,7 @@
3738
"codelyzer": "~3.2.0",
3839
"copy-webpack-plugin": "^4.0.1",
3940
"css-loader": "^0.28.1",
41+
"extract-text-webpack-plugin": "3.0.0",
4042
"file-loader": "^0.8.5",
4143
"html-loader": "^0.4.3",
4244
"html-webpack-plugin": "^2.26.0",
@@ -51,13 +53,13 @@
5153
"karma-jasmine-html-reporter": "^0.2.2",
5254
"karma-sourcemap-loader": "^0.3.7",
5355
"karma-webpack": "^2.0.4",
56+
"live-server": "1.2.0",
5457
"loader-utils": "^1.1.0",
5558
"node-sass": "^4.5.3",
5659
"protractor": "~5.1.2",
57-
"raw-loader": "^0.5.1",
5860
"reflect-metadata": "^0.1.10",
5961
"sass-loader": "^6.0.6",
60-
"style-loader": "^0.18.2",
62+
"to-string-loader": "^1.1.5",
6163
"tslint": "~5.7.0",
6264
"typescript": "~2.5.2",
6365
"webpack": "~3.4.1",

src/constants.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
$primary-color: #0064ff;
44
$primary-color-light: #3f86ff;
55

6-
$primary-bg: #ffffff;
6+
$primary-bg: #000000;
77
$primary-content-bg: #4b4b4b;
88

99
$primary-font: Tahoma, Arial, sans-serif;

src/global.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
body {
88
background-color: $primary-bg;
9-
color: $primary-color;
9+
color: #ffffff;
1010
font-family: $primary-font;
1111
font-size: $primary-font-size;
1212
}

0 commit comments

Comments
 (0)