-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
74 lines (70 loc) · 3.21 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = (env) => {
// Configuration in common to both client-side and server-side bundles
const isDevBuild = !(env && env.prod);
const sharedConfig = {
stats: { modules: false },
context: __dirname,
resolve: { extensions: ['.js','.ts'] },
output: {
filename: '[name].js',
publicPath: '/HarvestTheme/Content/' // Webpack dev middleware, if enabled, handles requests for this URL prefix
},
module: {
rules: [
{ test: /\.ts$/, use: ['awesome-typescript-loader?silent=true', 'angular2-template-loader'] },
{ test: /\.html$/, use: 'html-loader?minimize=false' },
//{ test: /\.css$/, use: ['to-string-loader', 'css-loader'] },
{ test: /\.css$/, use: ['to-string-loader', 'css-loader?importLoaders=1', 'postcss-loader'] },
{ test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' }
]
},
plugins: [new CheckerPlugin()]
};
// Configuration for client-side bundle suitable for running in browsers
const clientBundleOutputDir = '/src/Orchard.Cms.Web/Themes/HarvestTheme/Content/';
const clientBundleConfig = merge(sharedConfig, {
entry: { 'main': './src/Orchard.Cms.Web/Themes/HarvestTheme/ClientApp/main.ts' },
output: { path: path.join(__dirname, clientBundleOutputDir) },
plugins: [
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./src/Orchard.Cms.Web/Themes/HarvestTheme/Content/vendor-manifest.json')
})
].concat(isDevBuild ? [
// Plugins that apply in development builds only
new webpack.SourceMapDevToolPlugin({
filename: '[file].map', // Remove this line if you prefer inline source maps
moduleFilenameTemplate: path.relative(clientBundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk
})
] : [
// Plugins that apply in production builds only
new webpack.optimize.UglifyJsPlugin()
])
});
// Configuration for server-side (prerendering) bundle suitable for running in Node
//const serverBundleConfig = merge(sharedConfig, {
// resolve: { mainFields: ['main'] },
// entry: { 'main-server': './ClientApp/boot-server.ts' },
// plugins: [
// new webpack.DllReferencePlugin({
// context: __dirname,
// manifest: require('./ClientApp/dist/vendorsourceTypemanifest.json'),
// -: 'commonjs2',
// name: './vendor'
// })
// ],
// output: {
// libraryTarget: 'commonjs',
// path: path.join(__dirname, './ClientApp/dist')
// },
// target: 'node',
// devtool: 'inline-source-map'
//});
return clientBundleConfig;
//return [clientBundleConfig, serverBundleConfig];
};