Generic webpack config for Angular2 applications by @AngularClass
npm install ng2-webpack-config1. Copy all js files from samples folder to your application root folder
``bash`
cp -rf node_modules/ng2-webpack-config/samples/* .
cp -rf node_modules/ng2-webpack-config/samples/.ng2-config.js .
2. Copy ts and .d.ts files to your angular2 app root folder ('./src' for example)
`bash`
cp -rf node_modules/ng2-webpack-config/samples/src/*.ts ./src
3. Only 2 small steps left to get app and running:
- Open .ng2-config.js and update some fields if needed`js`
module.exports = {
// metadata
title: pkg.description,
baseUrl: '/',
// angular2 root folder name
src: 'src',
// dist folder name
dist: 'dist',
// entry html file
htmlIndexes: ['index.html'],
// karma bundle src
spec: './spec-bundle.js',
// webpack entry
entry: {
polyfills: './src/polyfills.ts',
vendor: './src/vendor.ts',
main: './src/index.ts'
},
// in most cases you don't need to change this line
commonChunks: {
name: ['polyfills', 'vendor'].reverse()
},
// webpack alias (just in case)
alias: {},
// copy any additional files you need
copy: [
{from: 'src/favicon.ico', to: 'favicon.ico'}
]
};spec-bundle.js
- Open and update PATH_TO_FILES const
1. Webpack dev build, run: $ webpack$ NODE_ENV=production webpack
2. Webpack prod build, run: $ karma start
3. Karma tests, run: $ protractor`
4. Protractor tests, run