diff --git a/webpack/webpack.aot-common.js b/webpack/webpack.aot-common.js new file mode 100644 index 0000000000000000000000000000000000000000..8c3153a3c91f6d1d96e1209f9d764e5fb574b6c8 --- /dev/null +++ b/webpack/webpack.aot-common.js @@ -0,0 +1,81 @@ +const webpack = require('webpack') +const path = require('path') +const HtmlWebpackPlugin = require('html-webpack-plugin') +const ngtools = require('@ngtools/webpack') +const AngularCompilerPlugin = ngtools.AngularCompilerPlugin +const merge = require('webpack-merge') +const staticAssets = require('./webpack.staticassets') + +const commonAot = { + entry: { + main: './src/main-aot.ts' + }, + output : { + filename : '[name].js', + path : path.resolve(__dirname,'../dist/aot') + }, + module: { + rules: [ + { + test : /third_party.*?\.js$|worker\.js|worker-\w+\.js/, + use : { + loader : 'file-loader', + options: { + name : '[name].[ext]' + } + } + }, + { + test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/, + loader: '@ngtools/webpack', + exclude : /third_party|plugin_example|spec\.ts|test\.ts/ + }, + { + test : /\.(html|css)$/, + exclude : /export\_nehuba|index|res\/css|plugin_example|material\/prebuilt-themes/, + use : { + loader : 'raw-loader', + } + }, + { + test : /res\/css.*?css$/, + use : { + loader : 'file-loader', + options : { + name : '[name].[ext]' + } + } + } + ] + }, + plugins : [ + new HtmlWebpackPlugin({ + template : 'src/index.html' + }), + new AngularCompilerPlugin({ + tsConfigPath: 'tsconfig-aot.json', + entryModule: 'src/main.module#MainModule', + directTemplateLoading: true + }), + new webpack.DefinePlugin({ + // TODO have to figure out how to set this properly + // needed to avoid inline eval + // shouldn't mode: 'production' do that already? + ngDevMode: false, + ngJitMode: false + }) + ], + resolve : { + extensions : [ + '.ts', + '.js', + '.json' + ], + alias : { + "third_party" : path.resolve(__dirname, '../third_party'), + "src" : path.resolve(__dirname, '../src') + } + } +} + +module.exports = merge(staticAssets, commonAot) \ No newline at end of file diff --git a/webpack/webpack.aot.js b/webpack/webpack.aot.js index 75cb504e183e0064768494a5865e513c7cae9a7d..0660ec650c1501aea74a41d9e617bb4fc2d9f005 100644 --- a/webpack/webpack.aot.js +++ b/webpack/webpack.aot.js @@ -1,90 +1,6 @@ -const common = require('./webpack.common.js') -const path = require('path') -const ngtools = require('@ngtools/webpack') -const HtmlWebpackPlugin = require('html-webpack-plugin') -const AngularCompilerPlugin = ngtools.AngularCompilerPlugin -const ClosureCompilerPlugin = require('webpack-closure-compiler') const merge = require('webpack-merge') -const staticAssets = require('./webpack.staticassets') -const TerserPlugin = require('terser-webpack-plugin') -const webpack = require('webpack') +const aotCommon = require('./webpack.aot-common') -module.exports = merge(staticAssets, { +module.exports = merge(aotCommon, { mode: 'production', - entry : { - main : './src/main-aot.ts' - }, - output : { - filename : '[name].js', - path : path.resolve(__dirname,'../dist/aot') - }, - module: { - rules: [ - { - test : /third_party.*?\.js$|worker\.js|worker-\w+\.js/, - use : { - loader : 'file-loader', - options: { - name : '[name].[ext]' - } - } - }, - { - test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/, - loader: '@ngtools/webpack', - exclude : /third_party|plugin_example|spec\.ts$/ - }, - { - test : /\.(html|css)$/, - exclude : /export\_nehuba|index|res\/css|plugin_example|material\/prebuilt-themes/, - use : { - loader : 'raw-loader', - } - }, - { - test : /res\/css.*?css$/, - use : { - loader : 'file-loader', - options : { - name : '[name].[ext]' - } - } - } - ] - }, - plugins : [ - new HtmlWebpackPlugin({ - template : 'src/index.html' - }), - new AngularCompilerPlugin({ - tsConfigPath: 'tsconfig-aot.json', - entryModule: 'src/main.module#MainModule', - directTemplateLoading: true - }), - new webpack.DefinePlugin({ - // TODO have to figure out how to set this properly - // needed to avoid inline eval - // shouldn't mode: 'production' do that already? - ngDevMode: false, - ngJitMode: false - }) - ], - optimization: { - minimizer: [ - new TerserPlugin({ - extractComments: false - }) - ] - }, - resolve : { - extensions : [ - '.ts', - '.js', - '.json' - ], - alias : { - "third_party" : path.resolve(__dirname,'../third_party'), - "src" : path.resolve(__dirname,'../src') - } - } -}) \ No newline at end of file +}) diff --git a/webpack/webpack.dev-aot.js b/webpack/webpack.dev-aot.js index 8adcad909ccbb08a9535246ab0c9b716b25966d2..7b43cfd18737e98a0e15fa229cd302729b7d90c5 100644 --- a/webpack/webpack.dev-aot.js +++ b/webpack/webpack.dev-aot.js @@ -1,84 +1,7 @@ -const common = require('./webpack.common.js') -const path = require('path') -const ngtools = require('@ngtools/webpack') -const HtmlWebpackPlugin = require('html-webpack-plugin') -const AngularCompilerPlugin = ngtools.AngularCompilerPlugin -const ClosureCompilerPlugin = require('webpack-closure-compiler') const merge = require('webpack-merge') -const staticAssets = require('./webpack.staticassets') -const TerserPlugin = require('terser-webpack-plugin') -const webpack = require('webpack') +const aotCommon = require('./webpack.aot-common') -module.exports = merge(staticAssets, { +module.exports = merge(aotCommon, { mode: 'development', - entry : { - main : './src/main-aot.ts' - }, - output : { - filename : '[name].js', - path : path.resolve(__dirname,'../dist/aot') - }, devtool:'source-map', - module: { - rules: [ - { - test : /third_party.*?\.js$|worker\.js|worker-\w+\.js/, - use : { - loader : 'file-loader', - options: { - name : '[name].[ext]' - } - } - }, - { - test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/, - loader: '@ngtools/webpack', - exclude : /third_party|plugin_example/ - }, - { - test : /\.(html|css)$/, - exclude : /export\_nehuba|index|res\/css|plugin_example|material\/prebuilt-themes/, - use : { - loader : 'raw-loader', - } - }, - { - test : /res\/css.*?css$/, - use : { - loader : 'file-loader', - options : { - name : '[name].[ext]' - } - } - } - ] - }, - plugins : [ - new HtmlWebpackPlugin({ - template : 'src/index.html' - }), - new AngularCompilerPlugin({ - tsConfigPath: 'tsconfig-aot.json', - entryModule: 'src/main.module#MainModule', - directTemplateLoading: true - }), - new webpack.DefinePlugin({ - // TODO have to figure out how to set this properly - // needed to avoid inline eval - // shouldn't mode: 'production' do that already? - ngDevMode: false, - ngJitMode: false - }) - ], - resolve : { - extensions : [ - '.ts', - '.js', - '.json' - ], - alias : { - "third_party" : path.resolve(__dirname, '../third_party'), - "src" : path.resolve(__dirname, '../src') - } - } })