Babel: use babel-loader instead of ts-loader, ng-annotate with babel-plugin-angularjs-annotate (#21554)

* Applied prettier to some webpack configs

* Removed ng-annotate

… and used same annotation approach as webpack.hot.js

* Removed redundant import

… that is problematic with Babel's module resolver

* Updated lockfile

* Replace ts-loader with babel-loader in webpack.dev

* Change tslint-loade order in dev webpack config

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
This commit is contained in:
Steven Vachon
2020-01-17 12:36:46 +01:00
committed by Dominik Prokop
co-authored by Dominik Prokop
parent 260239d98b
commit e7e0d18bc8
6 changed files with 538 additions and 254 deletions
+41 -35
View File
@@ -7,7 +7,7 @@ const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const IgnoreNotFoundExportPlugin = require("./IgnoreNotFoundExportPlugin.js");
const IgnoreNotFoundExportPlugin = require('./IgnoreNotFoundExportPlugin.js');
module.exports = merge(common, {
mode: 'development',
@@ -36,50 +36,56 @@ module.exports = merge(common, {
'!/public/build': 'http://localhost:3000',
},
watchOptions: {
ignored: /node_modules/
}
ignored: /node_modules/,
},
},
optimization: {
removeAvailableModules: false,
runtimeChunk: false,
removeEmptyChunks: false,
splitChunks: false
splitChunks: false,
},
module: {
rules: [{
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
options: {
cacheDirectory: true,
babelrc: false,
plugins: [
[require('@rtsao/plugin-proposal-class-properties'), {
loose: true
}],
'angularjs-annotate',
'@babel/plugin-syntax-dynamic-import', // needed for `() => import()` in routes.ts
'react-hot-loader/babel',
],
presets: [
[
'@babel/preset-env',
{
targets: {
browsers: 'last 3 versions'
use: [
{
loader: 'babel-loader',
options: {
cacheDirectory: true,
babelrc: false,
plugins: [
[
require('@rtsao/plugin-proposal-class-properties'),
{
loose: true,
},
useBuiltIns: 'entry',
modules: false
},
],
'angularjs-annotate',
'@babel/plugin-syntax-dynamic-import', // needed for `() => import()` in routes.ts
'react-hot-loader/babel',
],
'@babel/preset-typescript',
'@babel/preset-react',
],
presets: [
[
'@babel/preset-env',
{
targets: {
browsers: 'last 3 versions',
},
useBuiltIns: 'entry',
modules: false,
},
],
'@babel/preset-typescript',
'@babel/preset-react',
],
},
},
}, ],
],
},
{
test: /\.scss$/,
@@ -90,13 +96,13 @@ module.exports = merge(common, {
loader: 'postcss-loader',
options: {
config: {
path: __dirname + '/postcss.config.js'
path: __dirname + '/postcss.config.js',
},
},
},
{
loader: 'sass-loader'
}
loader: 'sass-loader',
},
],
},
{
@@ -113,7 +119,7 @@ module.exports = merge(common, {
template: path.resolve(__dirname, '../../public/views/index-template.html'),
inject: 'body',
alwaysWriteToDisk: true,
chunksSortMode: 'none'
chunksSortMode: 'none',
}),
new HtmlWebpackHarddiskPlugin(),
new webpack.NamedModulesPlugin(),