const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const autoprefixer = require('autoprefixer');
module.exports = {
entry: {
'main': [
'./src/styles.scss',
'./src/polyfills.ts',
'./src/main.ts',
]
},
mode: "development",
// mode: "production",
output: {
path: path.resolve(__dirname, 'dist'), // путь к каталогу выходных файлов - папка dist
publicPath: '/WWW/static/dist',
// filename: '[name].[hash].js'
filename: '[name].js'
},
devServer: {
compress: true,
port: 9000,
watchContentBase: true,
progress: true,
historyApiFallback: true,
},
resolve: {
extensions: ['.ts', '.js', '.json', '.css', '.scss', '.html']
},
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)$/,
use: [
{loader: 'to-string-loader'},
{loader: 'style-loader'},
{loader: 'css-loader'},
{
loader: 'postcss-loader',
options: {
plugins: [
autoprefixer({
browsers: ['ie >= 8', 'last 4 version']
})
],
sourceMap: true
}
},
{loader: 'sass-loader'}
]
}
]
},
plugins: [
new webpack.ContextReplacementPlugin(
/angular(\|\/)core/,
path.resolve(__dirname, 'src'), // каталог с исходными файлами
{} // карта маршрутов
),
new HtmlWebpackPlugin({
template: 'src/index.html'
}),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.LoaderOptionsPlugin({
htmlLoader: {
minimize: false
}
}),
]
};
{
test: /\.(css|sass|scss)$/,
exclude: path.resolve(__dirname, 'src/app'),
use: [
{
loader: 'css-loader',
options: {
minimize: true,
sourceMap: true
}
},
]
},
{
test: /\.(css|sass|scss)$/,
use: [
{
loader: 'postcss-loader',
options: {
plugins: [
autoprefixer({
browsers: ['ie >= 8', 'last 4 version']
})
],
sourceMap: true
}
},
{loader: 'sass-loader'}
]
}