Commit 9fff44bd authored by Matija Obreza's avatar Matija Obreza
Browse files

Webpack entrypoint

- Don't watch node_modules
parent e43964a7
...@@ -13,127 +13,129 @@ const ReactLoadable = require('react-loadable/webpack'); ...@@ -13,127 +13,129 @@ const ReactLoadable = require('react-loadable/webpack');
const fs = require('fs'); const fs = require('fs');
const HOST = process.env.HOST || 'localhost'; const HOST = process.env.HOST || '0.0.0.0';
const PORT = process.env.PORT || 3000; const PORT = process.env.PORT || 3000;
module.exports = { module.exports = {
stats: {
stats: { colors: true
colors: true },
},
devServer: {
devServer: { hot: true,
hot: true, inline: true,
inline: true, // contentBase: path.join(__dirname, '../'),
contentBase: path.join(__dirname, '../'), compress: true,
compress: true, port: PORT,
port: PORT, host: HOST,
host: HOST, watchOptions: {
overlay: { ignored: /node_modules/
warnings: true,
errors: true
},
clientLogLevel: 'warning',
historyApiFallback: {
disableDotRule: true
},
},
entry: {
gringlobal: [ 'babel-polyfill', './demo/App.tsx' ],
},
output: {
filename: '[name].[hash].js',
chunkFilename: '[name].[hash].js',
path: path.join(process.cwd(), 'target/app/assets'),
publicPath: ''
}, },
overlay: {
resolve: { warnings: true,
extensions: ['.ts', '.tsx', '.js', '.jsx'], errors: true
modules: [path.resolve('./src'), path.resolve('./server'), 'node_modules'],
alias: {
'@gringlobal/counter': path.resolve(__dirname, '../src'),
'@gringlobal/i18n': path.resolve(__dirname, '../../i18n/src'),
'server': path.resolve(__dirname, '../server'),
}
}, },
clientLogLevel: 'warning',
module: { historyApiFallback: {
rules: [ disableDotRule: true
{
test: /\.tsx?$/,
enforce: 'pre',
loader: 'eslint-loader',
exclude: /node_modules/,
},
{
test: /\.tsx?$/,
use: [
{
loader: 'awesome-typescript-loader',
},
],
},
]
}, },
plugins: [ },
/* new webpack.optimize.CommonsChunkPlugin({
entry: {
gringlobal: ['babel-polyfill', './demo/entrypoint.tsx'],
},
output: {
filename: '[name].[hash].js',
chunkFilename: '[name].[hash].js',
path: path.join(process.cwd(), 'target/app/assets'),
publicPath: ''
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
modules: [path.resolve('./src'), path.resolve('./server'), 'node_modules'],
alias: {
'@gringlobal/counter': path.resolve(__dirname, '../src'),
'@gringlobal/i18n': path.resolve(__dirname, '../../i18n/src'),
'server': path.resolve(__dirname, '../server'),
}
},
module: {
rules: [
{
test: /\.tsx?$/,
enforce: 'pre',
loader: 'eslint-loader',
exclude: /node_modules/,
},
{
test: /\.tsx?$/,
use: [
{
loader: 'awesome-typescript-loader',
},
],
},
]
},
plugins: [
/* new webpack.optimize.CommonsChunkPlugin({
name: 'vendor', name: 'vendor',
minChunks: Infinity minChunks: Infinity
}),*/ }),*/
// MD5 chunkhash // MD5 chunkhash
new WebpackChunkHash(), new WebpackChunkHash(),
// We use the generated manifest.js to look for current server.[hash].js and vendor.[chunkhash].js // We use the generated manifest.js to look for current server.[hash].js and vendor.[chunkhash].js
new ManifestPlugin({ new ManifestPlugin({
basePath: '/html/' basePath: '/html/'
}), }),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
title: 'Seed counter', // The title to use for the generated HTML document title: 'Seed counter', // The title to use for the generated HTML document
filename: 'index.html', // The file to write the HTML to filename: 'index.html', // The file to write the HTML to
// minify: {...}, // Pass a html-minifier options object to minify the output // minify: {...}, // Pass a html-minifier options object to minify the output
xhtml: true, xhtml: true,
excludeAssets: [/server(\..+)*\.js/], excludeAssets: [/server(\..+)*\.js/],
template: './assets/html/index.html', template: './assets/html/index.html',
// chunksSortMode: sortedChunks(['vendor', 'common', 'gringlobal']), // chunksSortMode: sortedChunks(['vendor', 'common', 'gringlobal']),
// chunks: ['vendor', 'common', 'gringlobal'], // chunks: ['vendor', 'common', 'gringlobal'],
favicon: 'favicon.ico', favicon: 'favicon.ico',
}), }),
// Defer/Async scripts // Defer/Async scripts
new ScriptExtHtmlWebpackPlugin({ new ScriptExtHtmlWebpackPlugin({
defaultAttribute: 'async', defaultAttribute: 'async',
// async: [ 'gringlobal' ], // async: [ 'gringlobal' ],
}), }),
// Keep CSS separate // Keep CSS separate
new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
filename: '[name].[hash].css', filename: '[name].[hash].css',
chunkFilename: '[name].[hash].css' chunkFilename: '[name].[hash].css'
}), }),
new HtmlWebpackExcludeAssetsPlugin(), new HtmlWebpackExcludeAssetsPlugin(),
new CopyWebpackPlugin([ new CopyWebpackPlugin([
{ from: 'assets/examples', to: 'examples' }, { from: 'assets/examples', to: 'examples' },
]), ]),
], ],
optimization: { optimization: {
splitChunks: { splitChunks: {
chunks: 'all', chunks: 'all',
cacheGroups: { cacheGroups: {
vendor: { vendor: {
test: /[\\/]node_modules[\\/]/, test: /[\\/]node_modules[\\/]/,
name: 'vendors', name: 'vendors',
chunks: 'all' chunks: 'all'
} }
}, },
}, },
} }
}; };
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<App />,
document.getElementById('the-app'),
);
...@@ -50,6 +50,9 @@ module.exports = { ...@@ -50,6 +50,9 @@ module.exports = {
compress: true, compress: true,
port: PORT, port: PORT,
host: HOST, host: HOST,
watchOptions: {
ignored: /node_modules/
},
overlay: { overlay: {
warnings: true, warnings: true,
errors: true errors: true
......
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