This commit is contained in:
Alexis Lahouze 2017-11-07 22:45:59 +01:00
parent b50d841862
commit 658a55b810

View File

@ -1,125 +1,127 @@
// vim: set tw=80 ts=2 sw=2 sts=2:
var webpack = require('webpack'); var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin'); var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin'); var ExtractTextPlugin = require('extract-text-webpack-plugin');
var helpers = require('./helpers'); var helpers = require('./helpers');
module.exports = { module.exports = {
entry: { entry: {
'polyfills': './src/polyfills.ts', 'polyfills': './src/polyfills.ts',
'vendor': './src/vendor.ts', 'vendor': './src/vendor.ts',
'app': './src/main.ts', 'app': './src/main.ts',
'styles': './src/main.scss' 'styles': './src/main.scss'
}, },
resolve: { resolve: {
extensions: ['.ts', '.js'], extensions: ['.ts', '.js'],
}, },
module: { module: {
rules: [{ rules: [{
enforce: 'pre', enforce: 'pre',
test: /webpack\.config\.js$/, test: /webpack\.config\.js$/,
include: helpers.root('src', 'app'), include: helpers.root('src', 'app'),
loader: 'eslint-loader', loader: 'eslint-loader',
options: { options: {
useEslintrc: false, useEslintrc: false,
emitWarning: true, emitWarning: true,
emitError: true, emitError: true,
failOnWarning: true, failOnWarning: true,
failOnError: true, failOnError: true,
baseConfig: 'webpack', baseConfig: 'webpack',
rules: { rules: {
indent: ['error', 4] indent: ['error', 4]
}, },
}, },
}, { }, {
// Javascript // Javascript
enforce: 'pre', enforce: 'pre',
test: /\.jsx?$/, test: /\.jsx?$/,
include: helpers.root('src', 'app'), include: helpers.root('src', 'app'),
loader: 'eslint-loader', loader: 'eslint-loader',
options: { options: {
useEslintrc: false, useEslintrc: false,
emitWarning: false, emitWarning: false,
emitError: true, emitError: true,
failOnWarning: false, failOnWarning: false,
failOnError: true, failOnError: true,
baseConfig: 'angular', baseConfig: 'angular',
rules: { rules: {
indent: ['error', 4] indent: ['error', 4]
}, },
plugins: [ plugins: [
'angular', 'angular',
'html', 'html',
'security', 'security',
'this', 'this',
'jquery', 'jquery',
'promise' 'promise'
] ]
}, },
// }, { // }, {
// test: /\.jsx?$/, // test: /\.jsx?$/,
// exclude: /node_modules/, // exclude: /node_modules/,
// loader: 'babel-loader' // loader: 'babel-loader'
}, { }, {
test: /\.ts?$/, test: /\.ts?$/,
//exclude: /node_modules/, //exclude: /node_modules/,
use: [ use: [
{ {
loader: 'awesome-typescript-loader', loader: 'awesome-typescript-loader',
options: { configFileName: helpers.root('src', 'tsconfig.json') } options: { configFileName: helpers.root('src', 'tsconfig.json') }
}, },
'angular2-template-loader' 'angular2-template-loader'
] ]
}, { }, {
test: /\.html$/, test: /\.html$/,
loader: 'html-loader' loader: 'html-loader'
}, { }, {
test: /\.less$/, test: /\.less$/,
use: [ use: [
'style-loader', 'style-loader',
'css-loader', 'css-loader',
'less-loader', 'less-loader',
] ]
}, { }, {
test: /\.css$/, test: /\.css$/,
exclude: helpers.root('src', 'app'), exclude: helpers.root('src', 'app'),
loader: ExtractTextPlugin.extract({ loader: ExtractTextPlugin.extract({
fallback: 'style-loader', fallback: 'style-loader',
use: 'css-loader?sourceMap' use: 'css-loader?sourceMap'
}) })
}, { }, {
test: /\.css$/, test: /\.css$/,
include: helpers.root('src', 'app'), include: helpers.root('src', 'app'),
loader: 'raw-loader' loader: 'raw-loader'
}, { }, {
test: /\.scss$/, test: /\.scss$/,
use: [ use: [
'style-loader', 'style-loader',
'css-loader', 'css-loader',
'sass-loader', 'sass-loader',
] ]
}, { }, {
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/, test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
loader: 'file-loader?name=assets/[name].[hash].[ext]' loader: 'file-loader?name=assets/[name].[hash].[ext]'
}] }]
}, },
plugins: [ plugins: [
// Workaround for angular/angular#11580 // Workaround for angular/angular#11580
new webpack.ContextReplacementPlugin( new webpack.ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows // The (\\|\/) piece accounts for path separators in *nix and Windows
/angular(\\|\/)core(\\|\/)@angular/, /angular(\\|\/)core(\\|\/)@angular/,
helpers.root('./src'), // location of your src helpers.root('./src'), // location of your src
{} // a map of your routes {} // a map of your routes
), ),
new webpack.optimize.CommonsChunkPlugin({ new webpack.optimize.CommonsChunkPlugin({
name: ['app', 'vendor', 'polyfills'] name: ['app', 'vendor', 'polyfills']
}), }),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
template: 'src/index.ejs' template: 'src/index.ejs'
}) })
], ],
}; };