Skip to content
This repository has been archived by the owner on Jan 18, 2019. It is now read-only.

Commit

Permalink
feat(webpack): Use new webpack config
Browse files Browse the repository at this point in the history
see #23
  • Loading branch information
hypery2k committed Jan 20, 2017
1 parent a4489fa commit 7d01143
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 35 deletions.
6 changes: 4 additions & 2 deletions etc/appConfig.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
var path = require("path"),
sourcePath = 'test/app',
sourceRoot = path.resolve(__dirname, '..', sourcePath);
distPath = 'dist',
sourceRoot = path.resolve(__dirname, '..', sourcePath),
distRoot = path.resolve(__dirname, '..', distPath);

var appConfig = {
srcPath: sourceRoot,
genPath: 'src-gen',
testPath: 'test/specs',
distPath: 'dist',
distPath: distRoot,
templatesPath: 'scripts/templates',
specs: '/**/*.spec.ts',
testBundle: path.resolve(__dirname, './spec-bundle.js'),
Expand Down
1 change: 1 addition & 0 deletions etc/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function mergeAppConfig(overwrittenConfig) { /*eslint complexity: [error, 22]*/
dist: appConfig.dist || path.resolve(distPath),
genPath: genPath,
junit: junit,
copy: appConfig.copy,
indexFiles: indexFiles,
gen: appConfig.gen || path.resolve(genPath),
chunks: appConfig.chunks || defaultAppConfig.chunks,
Expand Down
6 changes: 1 addition & 5 deletions etc/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ var config = {
// resolve https://github.com/holisticon/angular-common/issues/10
exprContextCritical: false,

noParse: [
/@angular|zone.js/
],

/*
* An array of automatically applied loaders.
*
Expand Down Expand Up @@ -193,7 +189,7 @@ var config = {
// TODO appConfig.srcSASS
{
test: /\.scss$/,
loaders: ["style", "css", "sass"]
loaders: ['style-loader', 'css-loader', 'sass-loader']
},
/*
* to string and css loader support for *.css files
Expand Down
30 changes: 2 additions & 28 deletions etc/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,6 @@ const METADATA = webpackMerge(commonConfig.metadata, {
*/
module.exports = webpackMerge(commonConfig, {

/**
* Merged metadata from webpack.common.js for index.html
*
* See: (custom attribute)
*/
metadata: METADATA,

/**
* Switch loaders to debug mode.
*
* See: http://webpack.github.io/docs/configuration.html#debug
*/
// debug: true,

/**
* Developer tool to enhance debugging
*
Expand Down Expand Up @@ -134,18 +120,6 @@ module.exports = webpackMerge(commonConfig, {
new OpenBrowserPlugin({ url: 'http://localhost:3000' })
],

/**
* Static analysis linter for TypeScript advanced options configuration
* Description: An extensible linter for the TypeScript language.
*
* See: https://github.com/wbuchwalter/tslint-loader
*/
tslint: {
emitErrors: false,
failOnHint: false,
resourcePath: 'src'
},

/**
* Webpack Development Server configuration
* Description: The webpack-dev-server is a little node.js Express server.
Expand All @@ -162,7 +136,7 @@ module.exports = webpackMerge(commonConfig, {
aggregateTimeout: 300,
poll: 1000
},
outputPath: appConfig.dist,
contentBase: appConfig.dist,
proxy: appConfig.proxy
},

Expand All @@ -173,7 +147,7 @@ module.exports = webpackMerge(commonConfig, {
* See: https://webpack.github.io/docs/configuration.html#node
*/
node: {
global: 'window',
global: true,
crypto: 'empty',
process: true,
module: false,
Expand Down
7 changes: 7 additions & 0 deletions test/helpers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,40 @@ describe('mergeAppConfig', () => {
var config = mergeAppConfig();
expect(config).toBeDefined();
var expectation = getAppConfig();
delete config['copy'];
delete config['junit'];
delete expectation['junit'];
delete expectation['copy'];
expect(config).toEqualJson(expectation);
});

it('should work with null config', () => {
var config = mergeAppConfig(null);
expect(config).toBeDefined();
var expectation = getAppConfig();
delete config['copy'];
delete config['junit'];
delete expectation['junit'];
delete expectation['copy'];
expect(config).toEqualJson(expectation);
});

it('should work with empty config', () => {
var config = mergeAppConfig({});
expect(config).toBeDefined();
var expectation = getAppConfig();
delete config['copy'];
delete config['junit'];
delete expectation['junit'];
delete expectation['copy'];
expect(config).toEqualJson(expectation);
});

it('should work with overwritten config', () => {
var config = mergeAppConfig({ srcPath: 'src', testPath: 'tests' });
expect(config).toBeDefined();
var expectation = getAppConfig();
delete config['copy'];
delete config['junit'];
delete expectation['junit'];
expect(config).not.toEqualJson(expectation);
Expand Down

0 comments on commit 7d01143

Please sign in to comment.