Fix #55 , and also added functionality for scripts global building

This commit is contained in:
Theophilus Omorebee
2017-09-14 12:58:16 +01:00
parent 2ac2aa0abc
commit 012a894c04
3 changed files with 12034 additions and 550 deletions

4334
package-lock.json generated

File diff suppressed because it is too large Load Diff

8185
src/assets/css/bootstrap.css vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -5,9 +5,10 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin');
const autoprefixer = require('autoprefixer'); const autoprefixer = require('autoprefixer');
const postcssUrl = require('postcss-url'); const postcssUrl = require('postcss-url');
const ConcatPlugin = require('webpack-concat-plugin');
const { NoEmitOnErrorsPlugin, LoaderOptionsPlugin, DefinePlugin, HashedModuleIdsPlugin } = require('webpack'); const { NoEmitOnErrorsPlugin, LoaderOptionsPlugin, DefinePlugin, HashedModuleIdsPlugin } = require('webpack');
const { GlobCopyWebpackPlugin, BaseHrefWebpackPlugin } = require('@angular/cli/plugins/webpack'); const { GlobCopyWebpackPlugin, BaseHrefWebpackPlugin, InsertConcatAssetsWebpackPlugin } = require('@angular/cli/plugins/webpack');
const { CommonsChunkPlugin, UglifyJsPlugin } = require('webpack').optimize; const { CommonsChunkPlugin, UglifyJsPlugin } = require('webpack').optimize;
const { AotPlugin } = require('@ngtools/webpack'); const { AotPlugin } = require('@ngtools/webpack');
@@ -18,6 +19,19 @@ const deployUrl = "";
const isProd = (process.env.NODE_ENV === 'production'); const isProd = (process.env.NODE_ENV === 'production');
//add all external css to be added in our index.html--> like as if it's .angular-cli.json
const styles = [
"./src/assets/css/bootstrap.css",
"./src/styles.scss"
];
//we add all our external scripts we want to load externally, like inserting in our index.html --> like as if it's .angular-cli.json
const scripts = [
];
//create file path for each , so we use for our excludes and includes where needed
let style_paths = styles.map(style_src => path.join(process.cwd(), style_src));
function getPlugins() { function getPlugins() {
var plugins = []; var plugins = [];
@@ -30,6 +44,19 @@ function getPlugins() {
plugins.push(new NoEmitOnErrorsPlugin()); plugins.push(new NoEmitOnErrorsPlugin());
if(scripts.length > 0){
plugins.push(new ConcatPlugin({
"uglify": false,
"sourceMap": true,
"name": "scripts",
"fileName": "[name].bundle.js",
"filesToConcat": scripts
}));
plugins.push(new InsertConcatAssetsWebpackPlugin([
"scripts"
]));
}
plugins.push(new GlobCopyWebpackPlugin({ plugins.push(new GlobCopyWebpackPlugin({
"patterns": [ "patterns": [
"assets", "assets",
@@ -225,9 +252,7 @@ module.exports = {
"polyfills": [ "polyfills": [
"./src/polyfills.ts" "./src/polyfills.ts"
], ],
"styles": [ "styles": styles
"./src/styles.scss"
]
}, },
"output": { "output": {
"path": path.join(process.cwd(), "dist"), "path": path.join(process.cwd(), "dist"),
@@ -258,9 +283,7 @@ module.exports = {
"loader": "url-loader?name=[name].[hash:20].[ext]&limit=10000" "loader": "url-loader?name=[name].[hash:20].[ext]&limit=10000"
}, },
{ {
"exclude": [ "exclude": style_paths,
path.join(process.cwd(), "src/styles.scss")
],
"test": /\.css$/, "test": /\.css$/,
"loaders": [ "loaders": [
"exports-loader?module.exports.toString()", "exports-loader?module.exports.toString()",
@@ -269,9 +292,7 @@ module.exports = {
] ]
}, },
{ {
"exclude": [ "exclude": style_paths,
path.join(process.cwd(), "src/styles.scss")
],
"test": /\.scss$|\.sass$/, "test": /\.scss$|\.sass$/,
"loaders": [ "loaders": [
"exports-loader?module.exports.toString()", "exports-loader?module.exports.toString()",
@@ -281,9 +302,7 @@ module.exports = {
] ]
}, },
{ {
"exclude": [ "exclude": style_paths,
path.join(process.cwd(), "src/styles.scss")
],
"test": /\.less$/, "test": /\.less$/,
"loaders": [ "loaders": [
"exports-loader?module.exports.toString()", "exports-loader?module.exports.toString()",
@@ -293,9 +312,7 @@ module.exports = {
] ]
}, },
{ {
"exclude": [ "exclude": style_paths,
path.join(process.cwd(), "src/styles.scss")
],
"test": /\.styl$/, "test": /\.styl$/,
"loaders": [ "loaders": [
"exports-loader?module.exports.toString()", "exports-loader?module.exports.toString()",
@@ -305,9 +322,7 @@ module.exports = {
] ]
}, },
{ {
"include": [ "include": style_paths,
path.join(process.cwd(), "src/styles.scss")
],
"test": /\.css$/, "test": /\.css$/,
"loaders": ExtractTextPlugin.extract({ "loaders": ExtractTextPlugin.extract({
"use": [ "use": [
@@ -319,9 +334,7 @@ module.exports = {
}) })
}, },
{ {
"include": [ "include": style_paths,
path.join(process.cwd(), "src/styles.scss")
],
"test": /\.scss$|\.sass$/, "test": /\.scss$|\.sass$/,
"loaders": ExtractTextPlugin.extract({ "loaders": ExtractTextPlugin.extract({
"use": [ "use": [
@@ -334,9 +347,7 @@ module.exports = {
}) })
}, },
{ {
"include": [ "include":style_paths,
path.join(process.cwd(), "src/styles.scss")
],
"test": /\.less$/, "test": /\.less$/,
"loaders": ExtractTextPlugin.extract({ "loaders": ExtractTextPlugin.extract({
"use": [ "use": [
@@ -349,9 +360,7 @@ module.exports = {
}) })
}, },
{ {
"include": [ "include": style_paths,
path.join(process.cwd(), "src/styles.scss")
],
"test": /\.styl$/, "test": /\.styl$/,
"loaders": ExtractTextPlugin.extract({ "loaders": ExtractTextPlugin.extract({
"use": [ "use": [