const path = require('path');
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); // плагин минимизации
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const autoprefixer = require('autoprefixer');
module.exports = {
entry: {
'polyfills': './src/polyfills.ts',
'app': './src/main.ts'
},
mode: "development",
// mode: "production",
output:{
path: path.resolve(__dirname, 'dist'), // путь к каталогу выходных файлов - папка public
publicPath: '/',
// filename: '[name].[hash].js'
filename: '[name].js'
},
devServer: {
compress: true,
port: 9000,
watchContentBase: true,
progress: true,
historyApiFallback: true,
},
resolve: {
extensions: ['.ts', '.js']
},
module:{
rules:[
{
test: /\.ts$/,
use: [
{
loader: 'awesome-typescript-loader',
options: { configFileName: path.resolve(__dirname, 'tsconfig.json') }
} ,
'angular2-template-loader'
]
},
{
test: /\.html$/,
loader: 'html-loader'
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
loader: 'file-loader?name=assets/[name].[ext]'
},
{
test: /\.(css|sass|scss)$/,
exclude: path.resolve(__dirname, 'src/app'),
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: {
plugins: [
autoprefixer({
browsers:['ie >= 8', 'last 4 version']
})
],
sourceMap: true
}
},
{
loader: 'sass-loader'
},
{
loader: 'raw-loader'
},
]
},
]
},
plugins: [
new webpack.ContextReplacementPlugin(
/angular(\|\/)core/,
path.resolve(__dirname, 'src'), // каталог с исходными файлами
{} // карта маршрутов
),
new HtmlWebpackPlugin({
template: 'src/index.html'
}),
new MiniCssExtractPlugin({
filename: "[name].css"
}),
new UglifyJSPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.LoaderOptionsPlugin({
htmlLoader: {
minimize: false
}
})
]
};