Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
# Conflicts:
#	package-lock.json
  • Loading branch information
Maxime GRIS committed Sep 26, 2017
2 parents 8c37cc4 + 41445eb commit 62ac244
Showing 1 changed file with 36 additions and 28 deletions.
64 changes: 36 additions & 28 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const autoprefixer = require('autoprefixer');
const postcssUrl = require('postcss-url');
const ConcatPlugin = require('webpack-concat-plugin');

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 { AotPlugin } = require('@ngtools/webpack');

Expand All @@ -18,6 +19,18 @@ const deployUrl = "";

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/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() {
var plugins = [];

Expand All @@ -30,6 +43,19 @@ function getPlugins() {

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({
"patterns": [
"assets",
Expand Down Expand Up @@ -225,9 +251,7 @@ module.exports = {
"polyfills": [
"./src/polyfills.ts"
],
"styles": [
"./src/styles.scss"
]
"styles": styles
},
"output": {
"path": path.join(process.cwd(), "dist"),
Expand Down Expand Up @@ -258,9 +282,7 @@ module.exports = {
"loader": "url-loader?name=[name].[hash:20].[ext]&limit=10000"
},
{
"exclude": [
path.join(process.cwd(), "src/styles.scss")
],
"exclude": style_paths,
"test": /\.css$/,
"loaders": [
"exports-loader?module.exports.toString()",
Expand All @@ -269,9 +291,7 @@ module.exports = {
]
},
{
"exclude": [
path.join(process.cwd(), "src/styles.scss")
],
"exclude": style_paths,
"test": /\.scss$|\.sass$/,
"loaders": [
"exports-loader?module.exports.toString()",
Expand All @@ -281,9 +301,7 @@ module.exports = {
]
},
{
"exclude": [
path.join(process.cwd(), "src/styles.scss")
],
"exclude": style_paths,
"test": /\.less$/,
"loaders": [
"exports-loader?module.exports.toString()",
Expand All @@ -293,9 +311,7 @@ module.exports = {
]
},
{
"exclude": [
path.join(process.cwd(), "src/styles.scss")
],
"exclude": style_paths,
"test": /\.styl$/,
"loaders": [
"exports-loader?module.exports.toString()",
Expand All @@ -305,9 +321,7 @@ module.exports = {
]
},
{
"include": [
path.join(process.cwd(), "src/styles.scss")
],
"include": style_paths,
"test": /\.css$/,
"loaders": ExtractTextPlugin.extract({
"use": [
Expand All @@ -319,9 +333,7 @@ module.exports = {
})
},
{
"include": [
path.join(process.cwd(), "src/styles.scss")
],
"include": style_paths,
"test": /\.scss$|\.sass$/,
"loaders": ExtractTextPlugin.extract({
"use": [
Expand All @@ -334,9 +346,7 @@ module.exports = {
})
},
{
"include": [
path.join(process.cwd(), "src/styles.scss")
],
"include":style_paths,
"test": /\.less$/,
"loaders": ExtractTextPlugin.extract({
"use": [
Expand All @@ -349,9 +359,7 @@ module.exports = {
})
},
{
"include": [
path.join(process.cwd(), "src/styles.scss")
],
"include": style_paths,
"test": /\.styl$/,
"loaders": ExtractTextPlugin.extract({
"use": [
Expand Down

0 comments on commit 62ac244

Please sign in to comment.