2018-12-09 00:36:25 -05:00
|
|
|
const path = require("path");
|
|
|
|
const webpack = require("webpack");
|
2017-05-26 23:51:48 -04:00
|
|
|
|
2018-12-09 00:36:25 -05:00
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
2017-05-26 23:51:48 -04:00
|
|
|
|
2018-12-09 00:36:25 -05:00
|
|
|
const isProd = process.env.npm_lifecycle_event.startsWith('build');
|
2017-05-26 23:51:48 -04:00
|
|
|
|
|
|
|
module.exports = function () {
|
2018-12-22 21:00:43 -05:00
|
|
|
const config = {};
|
2017-05-26 23:51:48 -04:00
|
|
|
|
|
|
|
if (isProd) config.devtool = 'source-map';
|
|
|
|
else config.devtool = 'eval-source-map';
|
|
|
|
|
|
|
|
config.entry = {
|
|
|
|
polyfills: './web/polyfills.ts',
|
|
|
|
vendor: './web/vendor.ts',
|
|
|
|
app: './web/main.ts'
|
|
|
|
};
|
|
|
|
|
|
|
|
config.output = {
|
2017-12-17 21:22:09 -05:00
|
|
|
path: path.join(root('build'), 'web'),
|
2017-05-27 01:08:24 -04:00
|
|
|
publicPath: isProd ? '/' : '/', //http://0.0.0.0:8080',
|
2017-05-26 23:51:48 -04:00
|
|
|
filename: isProd ? 'js/[name].[hash].js' : 'js/[name].js',
|
|
|
|
chunkFilename: isProd ? '[id].[hash].chunk.js' : '[id].chunk.js'
|
|
|
|
};
|
|
|
|
|
|
|
|
config.resolve = {
|
|
|
|
extensions: ['.ts', '.js', '.json', '.css', '.scss', '.html'],
|
|
|
|
};
|
|
|
|
|
|
|
|
config.module = {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
2018-12-22 21:00:43 -05:00
|
|
|
loaders: [{
|
|
|
|
loader: 'awesome-typescript-loader',
|
|
|
|
options: {
|
|
|
|
useCache: true,
|
|
|
|
useBabel: true,
|
|
|
|
babelOptions: {
|
|
|
|
babelrc: false,
|
|
|
|
presets: [
|
|
|
|
["@babel/preset-env", {"targets": "last 2 versions, ie 11", "modules": false}]
|
|
|
|
],
|
|
|
|
},
|
|
|
|
babelCore: "@babel/core",
|
|
|
|
},
|
|
|
|
}, 'angular2-template-loader', '@angularclass/hmr-loader'],
|
2017-05-26 23:51:48 -04:00
|
|
|
exclude: [/node_modules\/(?!(ng2-.+))/]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
|
|
|
loader: 'file-loader?name=fonts/[name].[hash].[ext]?'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
exclude: root('web', 'app'),
|
2018-12-09 00:36:25 -05:00
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
|
|
|
options: {}
|
|
|
|
},
|
|
|
|
"css-loader",
|
|
|
|
"postcss-loader"
|
|
|
|
]
|
2017-05-26 23:51:48 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
include: root('web', 'app'), loader: 'raw-loader!postcss-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(scss|sass)$/,
|
|
|
|
exclude: root('web', 'app'),
|
2018-12-09 00:36:25 -05:00
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
|
|
|
options: {}
|
|
|
|
},
|
|
|
|
"css-loader",
|
|
|
|
"postcss-loader",
|
|
|
|
"sass-loader"
|
|
|
|
]
|
2017-05-26 23:51:48 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(scss|sass)$/,
|
|
|
|
exclude: root('web', 'style'), loader: 'raw-loader!postcss-loader!sass-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.html$/, loader: 'raw-loader',
|
|
|
|
exclude: root('web', 'public')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
enforce: 'pre',
|
|
|
|
loader: 'tslint-loader'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
config.plugins = [
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env': {
|
|
|
|
ENV: JSON.stringify(process.env.npm_lifecycle_event)
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
new webpack.ContextReplacementPlugin(
|
|
|
|
/angular(\\|\/)core(\\|\/)@angular/,
|
|
|
|
root('./web') // location of your src
|
2018-12-09 00:36:25 -05:00
|
|
|
),
|
|
|
|
new webpack.LoaderOptionsPlugin({
|
2017-05-26 23:51:48 -04:00
|
|
|
options: {
|
|
|
|
tslint: {
|
|
|
|
emitErrors: false,
|
|
|
|
failOnHint: false
|
|
|
|
},
|
|
|
|
sassLoader: {
|
|
|
|
//includePaths: [path.resolve(__dirname, "node_modules/foundation-sites/scss")]
|
2017-05-29 16:03:37 -04:00
|
|
|
}
|
2017-05-26 23:51:48 -04:00
|
|
|
}
|
|
|
|
}),
|
2018-12-09 00:36:25 -05:00
|
|
|
new HtmlWebpackPlugin({
|
2017-05-26 23:51:48 -04:00
|
|
|
template: './web/public/index.html',
|
|
|
|
chunksSortMode: 'dependency'
|
2019-02-02 16:00:54 -05:00
|
|
|
}),
|
|
|
|
new CopyWebpackPlugin([{
|
|
|
|
from: root('web/public')
|
|
|
|
}]),
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: 'css/[name].[hash].css',
|
2018-12-09 00:36:25 -05:00
|
|
|
})
|
2017-05-26 23:51:48 -04:00
|
|
|
];
|
|
|
|
|
|
|
|
config.devServer = {
|
|
|
|
contentBase: './web/public',
|
|
|
|
historyApiFallback: true,
|
2017-06-26 00:07:41 -04:00
|
|
|
disableHostCheck: true,
|
2019-02-02 16:00:54 -05:00
|
|
|
quiet: false,
|
|
|
|
//stats: 'minimal',
|
2017-05-26 23:51:48 -04:00
|
|
|
proxy: {
|
|
|
|
'/api': {
|
|
|
|
target: 'http://localhost:8184',
|
|
|
|
secure: false
|
2019-06-27 23:46:00 -04:00
|
|
|
},
|
|
|
|
'/_matrix': {
|
|
|
|
target: 'http://localhost:8184',
|
|
|
|
secure: false
|
|
|
|
},
|
2017-05-26 23:51:48 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return config;
|
|
|
|
};
|
|
|
|
|
|
|
|
function root(args) {
|
|
|
|
args = Array.prototype.slice.call(arguments, 0);
|
|
|
|
return path.join.apply(path, [__dirname].concat(args));
|
|
|
|
}
|