Default #new
const path = require('path');
const { CommonsChunkPlugin, OccurrenceOrderPlugin } = require('webpack').optimize;
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry : {
'app': './src/main'
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
resolve: {
extensions: ['.js', '.ts']
},
module: {
loaders: [
{
test: /\.ts$/,
loader: 'awesome-typescript-loader',
exclude: /node_modules/
},
{
test: /\.html$/,
loader: 'raw-loader',
},
{
test: /\.css$/,
loaders: ['to-string-loader'].concat(ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader?sourceMap',
publicPath: '../../styles/'
}))
},
{
test: /\.(eot|svg|cur)$/,
loader: 'file-loader?publicPath=./&name=[name].[ext]?[hash:20]'
},
{
test: /\.(jpg|png|webp|gif|otf|ttf|woff|woff2|ani)$/,
loader: 'url-loader?publicPath=./&name=[name].[ext]?[hash:20]&limit=10000'
},
]
},
plugins: [
new CompressionPlugin({ regExp: /\.css$|\.html$|\.js$|\.map$/ }),
new CopyWebpackPlugin([{ from: './src/index.html', to: 'index.html'}]),
new OccurrenceOrderPlugin(true),
new ExtractTextPlugin("styles.css")
],
devServer: {
contentBase: 'src',
historyApiFallback: true,
stats: {
maxModules: 0,
warnings: false
},
port: 19999
},
devtool: 'source-map',
stats: {
maxModules: 0,
warnings: false
}
};
Default #old
const path = require('path');
const { CommonsChunkPlugin, OccurrenceOrderPlugin } = require('webpack').optimize;
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry : {
'app': './src/main'
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
resolve: {
extensions: ['.js', '.ts']
},
module: {
loaders: [
{
test: /\.ts$/,
loader: 'awesome-typescript-loader',
exclude: /node_modules/
},
{
test: /\.html$/,
loader: 'raw-loader',
},
{
test: /\.css$/,
loaders: ['to-string-loader', 'style-loader', 'css-loader']
},
{
test: /\.(eot|svg|cur)$/,
loader: 'file-loader'
},
{
test: /\.(jpg|png|webp|gif|otf|ttf|woff|woff2|ani)$/,
loader: 'url-loader'
},
]
},
plugins: [
new CompressionPlugin({ regExp: /\.css$|\.html$|\.js$|\.map$/ }),
new CopyWebpackPlugin([{ from: './src/index.html', to: 'index.html'}]),
new OccurrenceOrderPlugin(true),
],
devServer: {
contentBase: 'src',
historyApiFallback: true,
stats: {
maxModules: 0,
warnings: false
},
port: 19999
},
devtool: 'source-map',
stats: {
maxModules: 0,
warnings: false
}
};