Commit dd66cbc8 by David Kaltschmidt

Use babel and hot loader only in yarn start

* moved babel rules for hot reloading into TS loader
* toggling use of babel via HOT variable (true with `yarn start`)
* overriding webpack output when HOT to fix asset paths in dashboard
 urls like http://localhost:3333/d/...
parent ca25a253
...@@ -31,11 +31,24 @@ const entries = HOT ? { ...@@ -31,11 +31,24 @@ const entries = HOT ? {
vendor: require('./dependencies'), vendor: require('./dependencies'),
}; };
const output = HOT ? {
path: path.resolve(__dirname, '../../public/build'),
filename: '[name].[hash].js',
publicPath: "/public/build/",
} : {
path: path.resolve(__dirname, '../../public/build'),
filename: '[name].[hash].js',
// Keep publicPath relative for host.com/grafana/ deployments
publicPath: "public/build/",
};
module.exports = merge(common, { module.exports = merge(common, {
devtool: "cheap-module-source-map", devtool: "cheap-module-source-map",
entry: entries, entry: entries,
output: output,
resolve: { resolve: {
extensions: ['.scss', '.ts', '.tsx', '.es6', '.js', '.json', '.svg', '.woff2', '.png'], extensions: ['.scss', '.ts', '.tsx', '.es6', '.js', '.json', '.svg', '.woff2', '.png'],
}, },
...@@ -66,23 +79,20 @@ module.exports = merge(common, { ...@@ -66,23 +79,20 @@ module.exports = merge(common, {
{ {
test: /\.tsx?$/, test: /\.tsx?$/,
exclude: /node_modules/, exclude: /node_modules/,
use: [ use: {
{ loader: 'awesome-typescript-loader',
loader: 'babel-loader', options: {
options: { useCache: true,
useBabel: HOT,
babelOptions: {
babelrc: false,
plugins: [ plugins: [
'syntax-dynamic-import', 'syntax-dynamic-import',
'react-hot-loader/babel', 'react-hot-loader/babel'
], ]
}, }
}, },
{ }
loader: 'awesome-typescript-loader',
options: {
useCache: true,
},
}
]
}, },
require('./sass.rule.js')({ require('./sass.rule.js')({
sourceMap: true, minimize: false, preserveUrl: HOT sourceMap: true, minimize: false, preserveUrl: HOT
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment