-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/new root directory syntax (#1)
* added project args to config * Refactored configs to a single class and instance for env and path reasons * Updated the ng serve command to respect the new class instance 🔥
- Loading branch information
1 parent
6f77db5
commit d52fb7f
Showing
14 changed files
with
445 additions
and
423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,93 @@ | ||
import * as webpack from 'webpack'; | ||
import {ngAppResolve} from './webpack-build-utils'; | ||
|
||
const path = require('path'); | ||
const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin; | ||
const CopyWebpackPlugin = require('copy-webpack-plugin'); | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const DebugWebpackPlugin = require('debug-webpack-plugin'); | ||
|
||
export const webpackCommonConfig = { | ||
devtool: 'inline-source-map', | ||
resolve: { | ||
extensions: ['', '.ts', '.js'], | ||
root: ngAppResolve('./src') | ||
}, | ||
context: path.resolve(__dirname, './'), | ||
entry: { | ||
main: [ngAppResolve('./src/main.ts')], | ||
vendor: ngAppResolve('./src/vendor.ts'), | ||
polyfills: ngAppResolve('./src/polyfills.ts') | ||
}, | ||
output: { | ||
path: ngAppResolve('./dist'), | ||
filename: '[name].bundle.js' | ||
}, | ||
module: { | ||
preLoaders: [ | ||
{ | ||
test: /\.js$/, | ||
loader: 'source-map-loader', | ||
exclude: [ | ||
ngAppResolve('node_modules/rxjs'), | ||
ngAppResolve('node_modules/@angular'), | ||
] | ||
} | ||
], | ||
loaders: [ | ||
{ | ||
test: /\.ts$/, | ||
loaders: [ | ||
{ | ||
loader: 'awesome-typescript-loader', | ||
query: { | ||
useWebpackText: true, | ||
tsconfig: ngAppResolve('./src/tsconfig.json'), | ||
// resolveGlobs: false, | ||
module: "es2015", | ||
target: "es5", | ||
lib: ['es6', 'dom'], | ||
useForkChecker: true | ||
export const getWebpackCommonConfig = function(projectRoot: string) { | ||
return { | ||
devtool: 'inline-source-map', | ||
resolve: { | ||
extensions: ['', '.ts', '.js'], | ||
root: path.resolve(projectRoot, './src') | ||
}, | ||
context: path.resolve(__dirname, './'), | ||
entry: { | ||
main: [path.resolve(projectRoot, './src/main.ts')], | ||
vendor: path.resolve(projectRoot, './src/vendor.ts'), | ||
polyfills: path.resolve(projectRoot, './src/polyfills.ts') | ||
}, | ||
output: { | ||
path: path.resolve(projectRoot, './dist'), | ||
filename: '[name].bundle.js' | ||
}, | ||
module: { | ||
preLoaders: [ | ||
{ | ||
test: /\.js$/, | ||
loader: 'source-map-loader', | ||
exclude: [ | ||
path.resolve(projectRoot, 'node_modules/rxjs'), | ||
path.resolve(projectRoot, 'node_modules/@angular'), | ||
] | ||
} | ||
], | ||
loaders: [ | ||
{ | ||
test: /\.ts$/, | ||
loaders: [ | ||
{ | ||
loader: 'awesome-typescript-loader', | ||
query: { | ||
useWebpackText: true, | ||
tsconfig: path.resolve(projectRoot, './src/tsconfig.json'), | ||
// resolveGlobs: false, | ||
module: "es2015", | ||
target: "es5", | ||
lib: ['es6', 'dom'], | ||
useForkChecker: true | ||
} | ||
}, | ||
{ | ||
loader: 'angular2-template-loader' | ||
} | ||
}, | ||
{ | ||
loader: 'angular2-template-loader' | ||
} | ||
], | ||
exclude: [/\.(spec|e2e)\.ts$/] | ||
}, | ||
{ test: /\.json$/, loader: 'json-loader'}, | ||
{ test: /\.css$/, loaders: ['raw-loader', 'postcss-loader'] }, | ||
{ test: /\.styl$/, loaders: ['raw-loader', 'postcss-loader', 'stylus-loader'] }, | ||
{ test: /\.less$/, loaders: ['raw-loader', 'postcss-loader', 'less-loader'] }, | ||
{ test: /\.scss$/, loaders: ['raw-loader', 'postcss-loader', 'sass-loader'] }, | ||
{ test: /\.(jpg|png)$/, loader: 'url-loader?limit=128000'}, | ||
{ test: /\.html$/, loader: 'raw-loader' } | ||
] | ||
}, | ||
plugins: [ | ||
new ForkCheckerPlugin(), | ||
new HtmlWebpackPlugin({ | ||
template: ngAppResolve('src/index.html'), | ||
chunksSortMode: 'dependency' | ||
}), | ||
new webpack.optimize.CommonsChunkPlugin({ | ||
name: ['polyfills', 'vendor'].reverse() | ||
}), | ||
new webpack.optimize.CommonsChunkPlugin({ | ||
minChunks: Infinity, | ||
name: 'inline', | ||
filename: 'inline.js', | ||
sourceMapFilename: 'inline.map' | ||
}), | ||
new CopyWebpackPlugin([{from: ngAppResolve('./public'), to: ngAppResolve('./dist/public')}]) | ||
], | ||
node: { | ||
global: 'window', | ||
crypto: 'empty', | ||
module: false, | ||
clearImmediate: false, | ||
setImmediate: false | ||
], | ||
exclude: [/\.(spec|e2e)\.ts$/] | ||
}, | ||
{ test: /\.json$/, loader: 'json-loader'}, | ||
{ test: /\.css$/, loaders: ['raw-loader', 'postcss-loader'] }, | ||
{ test: /\.styl$/, loaders: ['raw-loader', 'postcss-loader', 'stylus-loader'] }, | ||
{ test: /\.less$/, loaders: ['raw-loader', 'postcss-loader', 'less-loader'] }, | ||
{ test: /\.scss$/, loaders: ['raw-loader', 'postcss-loader', 'sass-loader'] }, | ||
{ test: /\.(jpg|png)$/, loader: 'url-loader?limit=128000'}, | ||
{ test: /\.html$/, loader: 'raw-loader' } | ||
] | ||
}, | ||
plugins: [ | ||
new ForkCheckerPlugin(), | ||
new HtmlWebpackPlugin({ | ||
template: path.resolve(projectRoot, 'src/index.html'), | ||
chunksSortMode: 'dependency' | ||
}), | ||
new webpack.optimize.CommonsChunkPlugin({ | ||
name: ['polyfills', 'vendor'].reverse() | ||
}), | ||
new webpack.optimize.CommonsChunkPlugin({ | ||
minChunks: Infinity, | ||
name: 'inline', | ||
filename: 'inline.js', | ||
sourceMapFilename: 'inline.map' | ||
}), | ||
new CopyWebpackPlugin([{from: path.resolve(projectRoot, './public'), to: path.resolve(projectRoot, './dist/public')}]) | ||
], | ||
node: { | ||
global: 'window', | ||
crypto: 'empty', | ||
module: false, | ||
clearImmediate: false, | ||
setImmediate: false | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,27 @@ | ||
import { webpackCommonConfig } from '../models'; | ||
import { webpackMaterialConfig, webpackMaterialE2EConfig } from './webpack-build-material2'; | ||
import { ngAppResolve } from './webpack-build-utils'; | ||
const path = require('path') | ||
|
||
const webpackMerge = require('webpack-merge'); | ||
|
||
const devConfigPartial = { | ||
debug: true, | ||
devtool: 'cheap-module-source-map', | ||
output: { | ||
path: ngAppResolve('./dist'), | ||
filename: '[name].bundle.js', | ||
sourceMapFilename: '[name].map', | ||
chunkFilename: '[id].chunk.js' | ||
}, | ||
tslint: { | ||
emitErrors: false, | ||
failOnHint: false, | ||
resourcePath: ngAppResolve('./src') | ||
}, | ||
node: { | ||
global: 'window', | ||
crypto: 'empty', | ||
process: true, | ||
module: false, | ||
clearImmediate: false, | ||
setImmediate: false | ||
} | ||
export const getWebpackDevConfigPartial = function(projectRoot: string) { | ||
return { | ||
debug: true, | ||
devtool: 'cheap-module-source-map', | ||
output: { | ||
path: path.resolve(projectRoot, './dist'), | ||
filename: '[name].bundle.js', | ||
sourceMapFilename: '[name].map', | ||
chunkFilename: '[id].chunk.js' | ||
}, | ||
tslint: { | ||
emitErrors: false, | ||
failOnHint: false, | ||
resourcePath: path.resolve(projectRoot, './src') | ||
}, | ||
node: { | ||
global: 'window', | ||
crypto: 'empty', | ||
process: true, | ||
module: false, | ||
clearImmediate: false, | ||
setImmediate: false | ||
} | ||
}; | ||
} | ||
|
||
export const webpackDevConfig = webpackMerge(webpackCommonConfig, devConfigPartial); | ||
|
||
export const webpackDevMaterialConfig = webpackMerge(webpackMaterialConfig, devConfigPartial); | ||
|
||
export const webpackDevMaterialE2EConfig = webpackMerge(webpackMaterialE2EConfig, devConfigPartial); |
Oops, something went wrong.