Created
November 8, 2019 13:19
-
-
Save KingDarBoja/940125eaa23edecee2a8a173f1938cf4 to your computer and use it in GitHub Desktop.
Basic example of webpack configuration file using Typescript for any ng-toolkit generated project.
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 | |
import path from 'path'; | |
import webpack from 'webpack'; | |
const config: webpack.Configuration = { | |
mode: 'none', | |
entry: { | |
// This is our Express server for Dynamic universal | |
server: './server.ts', | |
prerender: './prerender.ts', | |
}, | |
target: 'node', | |
resolve: { extensions: ['.ts', '.js'] }, | |
optimization: { | |
minimize: false, | |
}, | |
output: { | |
libraryTarget: 'commonjs2', | |
// Puts the output at the root of the dist folder | |
path: path.resolve(process.cwd(), 'dist'), | |
filename: '[name].js', | |
}, | |
module: { | |
rules: [ | |
{ test: /\.ts$/, loader: 'ts-loader' }, | |
{ | |
// Mark files inside `@angular/core` as using SystemJS style dynamic imports. | |
// Removing this will cause deprecation warnings to appear. | |
test: /(\\|\/)@angular(\\|\/)core(\\|\/).+\.js$/, | |
parser: { system: true }, | |
}, | |
], | |
}, | |
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'), | |
{}, | |
), | |
], | |
}; | |
export default config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment