Last active
January 21, 2019 10:34
-
-
Save johnzondr/3d4a361ffcfe89f7ee5199dcc13bf246 to your computer and use it in GitHub Desktop.
Webpack config for angular 6 SSR
This file contains hidden or 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
// Work around for https://github.com/angular/angular-cli/issues/7200 | |
const path = require('path'); | |
const webpack = require('webpack'); | |
module.exports = { | |
entry: { | |
// This is our Express server for Dynamic universal | |
server: './server.ts', | |
// This is an example of Static prerendering (generative) | |
// prerender: './prerender.ts' | |
}, | |
target: 'node', | |
resolve: { extensions: ['.ts', '.js'] }, | |
optimization: { | |
// keep minimization off | |
// workaround for https://github.com/angular/angular-cli/issues/10635 | |
minimize: false | |
}, | |
// Make sure we include all node_modules etc | |
externals: [/(node_modules|main\..*\.js)/,], | |
output: { | |
// Puts the output at the root of the dist folder | |
path: path.join(__dirname, 'dist'), | |
filename: '[name].js' | |
}, | |
module: { | |
rules: [ | |
{ test: /\.ts$/, loader: 'ts-loader' } | |
] | |
}, | |
plugins: [ | |
new webpack.ContextReplacementPlugin( | |
// fixes WARNING Critical dependency: the request of a dependency is an expression | |
/(.+)?angular(\\|\/)core(.+)?/, | |
path.join(__dirname, 'src'), // location of your src | |
{} // a map of your routes | |
), | |
new webpack.ContextReplacementPlugin( | |
// fixes WARNING Critical dependency: the request of a dependency is an expression | |
/(.+)?express(\\|\/)(.+)?/, | |
path.join(__dirname, 'src'), | |
{} | |
) | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment