Improve webpack configuration.

This commit is contained in:
Alexis Lahouze 2017-09-03 00:45:06 +02:00
parent 04433bed3e
commit 6800b1ee2d
2 changed files with 13 additions and 19 deletions

View File

@ -4,6 +4,9 @@
"repository": "https://git.lahouze.org/xals/accountant", "repository": "https://git.lahouze.org/xals/accountant",
"license": "AGPL-1.0", "license": "AGPL-1.0",
"devDependencies": { "devDependencies": {
"@types/requirejs": "^2.1.31",
"angular2-template-loader": "^0.6.2",
"awesome-typescript-loader": "^3.2.3",
"babel-core": "^6.26.0", "babel-core": "^6.26.0",
"babel-eslint": "^8.0.1", "babel-eslint": "^8.0.1",
"babel-loader": "^7.1.2", "babel-loader": "^7.1.2",

View File

@ -2,6 +2,7 @@
const path = require('path'); const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack'); const webpack = require('webpack');
const helpers = require('./config/helpers');
module.exports = { module.exports = {
context: path.resolve(__dirname, 'src'), context: path.resolve(__dirname, 'src'),
@ -15,7 +16,7 @@ module.exports = {
}, },
devtool: 'source-map', devtool: 'source-map',
resolve: { resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.html'], extensions: ['.js', '.ts', '.html'],
}, },
module: { module: {
rules: [{ rules: [{
@ -37,7 +38,7 @@ module.exports = {
}, { }, {
// Javascript // Javascript
enforce: 'pre', enforce: 'pre',
test: /\.jsx?$/, test: /\.js$/,
//include: path.resolve(__dirname, 'src'), //include: path.resolve(__dirname, 'src'),
loader: 'eslint-loader', loader: 'eslint-loader',
options: { options: {
@ -60,13 +61,13 @@ module.exports = {
] ]
}, },
}, { }, {
test: /\.jsx?$/, test: /\.js$/,
exclude: /node_modules/, exclude: /node_modules/,
loader: 'babel-loader' loader: 'babel-loader'
}, { }, {
// Typescript linting // Typescript linting
enforce: 'pre', enforce: 'pre',
test: /\.tsx?$/, test: /\.ts$/,
loader: 'tslint-loader', loader: 'tslint-loader',
options: { options: {
configuration: { configuration: {
@ -87,31 +88,21 @@ module.exports = {
formattersDirectory: 'node_modules/tslint/lib/formatters/', formattersDirectory: 'node_modules/tslint/lib/formatters/',
} }
}, { }, {
test: /\.tsx?$/, test: /\.ts$/,
exclude: /node_modules/, exclude: /node_modules/,
loader: 'ts-loader' loaders: ['awesome-typescript-loader', 'angular2-template-loader?keepUrl=true']
}, { }, {
test: /\.html$/, test: /\.html$/,
use: [ loader: 'raw-loader'
'ngtemplate-loader?relativeTo=/accountant-ui/src',
'html-loader'
]
}, {
test: /\.less$/,
use: [
'style-loader',
'css-loader',
'less-loader',
]
}, { }, {
test: /\.css$/, test: /\.css$/,
use: [ loaders: [
'style-loader', 'style-loader',
'css-loader', 'css-loader',
] ]
}, { }, {
test: /\.scss$/, test: /\.scss$/,
use: [ loaders: [
'style-loader', 'style-loader',
'css-loader', 'css-loader',
'sass-loader', 'sass-loader',