Add template title and retab webpack files

This commit is contained in:
Lukas Martinelli 2016-12-16 15:04:17 +01:00
parent 7c93ad0a24
commit 71de62565b
3 changed files with 115 additions and 114 deletions

View file

@ -6,6 +6,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
</head> </head>
<body> <body>
<div id="app">Loading...</div> <div id="app">Loading...</div>
</body> </body>
</html> </html>

View file

@ -9,81 +9,82 @@ const PORT = process.env.PORT || "8888";
// global css // global css
loaders.push({ loaders.push({
test: /[\/\\](node_modules|global)[\/\\].*\.css$/, test: /[\/\\](node_modules|global)[\/\\].*\.css$/,
loaders: [ loaders: [
'style?sourceMap', 'style?sourceMap',
'css' 'css'
] ]
}); });
// local scss modules // local scss modules
loaders.push({ loaders.push({
test: /[\/\\]src[\/\\].*\.scss/, test: /[\/\\]src[\/\\].*\.scss/,
loaders: [ loaders: [
'style?sourceMap', 'style?sourceMap',
'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]', 'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]',
'sass' 'sass'
] ]
}); });
// local css modules // local css modules
loaders.push({ loaders.push({
test: /[\/\\]src[\/\\].*\.css/, test: /[\/\\]src[\/\\].*\.css/,
loaders: [ loaders: [
'style?sourceMap', 'style?sourceMap',
'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]' 'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]'
] ]
}); });
module.exports = { module.exports = {
target: 'web', target: 'web',
entry: [ entry: [
`webpack-dev-server/client?http://${HOST}:${PORT}`, `webpack-dev-server/client?http://${HOST}:${PORT}`,
`webpack/hot/only-dev-server`, `webpack/hot/only-dev-server`,
`./src/index.jsx` // Your appʼs entry point `./src/index.jsx` // Your appʼs entry point
], ],
devtool: process.env.WEBPACK_DEVTOOL || 'cheap-module-source-map', devtool: process.env.WEBPACK_DEVTOOL || 'cheap-module-source-map',
output: { output: {
path: path.join(__dirname, 'public'), path: path.join(__dirname, 'public'),
filename: 'bundle.js' filename: 'bundle.js'
}, },
resolve: { resolve: {
alias: { alias: {
'webworkify': 'webworkify-webpack', 'webworkify': 'webworkify-webpack',
// TODO: otherwise I get a max call stack error in browser? // TODO: otherwise I get a max call stack error in browser?
// 'mapbox-gl': path.resolve('./node_modules/mapbox-gl/dist/mapbox-gl.js') // 'mapbox-gl': path.resolve('./node_modules/mapbox-gl/dist/mapbox-gl.js')
}, },
extensions: ['', '.js', '.jsx'] extensions: ['', '.js', '.jsx']
}, },
module: { module: {
loaders, loaders,
postLoaders: [{ postLoaders: [{
include: /node_modules\/mapbox-gl-shaders/, include: /node_modules\/mapbox-gl-shaders/,
loader: 'transform', loader: 'transform',
query: 'brfs' query: 'brfs'
}] }]
}, },
node: { node: {
fs: "empty", fs: "empty",
net: 'empty', net: 'empty',
tls: 'empty' tls: 'empty'
}, },
devServer: { devServer: {
contentBase: "./public", contentBase: "./public",
// do not print bundle build stats // do not print bundle build stats
noInfo: true, noInfo: true,
// enable HMR // enable HMR
hot: true, hot: true,
// embed the webpack-dev-server runtime into the bundle // embed the webpack-dev-server runtime into the bundle
inline: true, inline: true,
// serve index.html in place of 404 responses to allow HTML5 history // serve index.html in place of 404 responses to allow HTML5 history
historyApiFallback: true, historyApiFallback: true,
port: PORT, port: PORT,
host: HOST host: HOST
}, },
plugins: [ plugins: [
new webpack.NoErrorsPlugin(), new webpack.NoErrorsPlugin(),
new webpack.HotModuleReplacementPlugin(), new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
template: './src/template.html' title: 'Maputnik',
}), template: './src/template.html'
] }),
]
}; };

View file

@ -1,49 +1,49 @@
module.exports = [ module.exports = [
{ {
test: /\.jsx?$/, test: /\.jsx?$/,
exclude: /(node_modules|bower_components|public)/, exclude: /(node_modules|bower_components|public)/,
loaders: ['react-hot-loader/webpack'] loaders: ['react-hot-loader/webpack']
}, },
{ {
test: /\.jsx?$/, test: /\.jsx?$/,
exclude: /(node_modules|bower_components|public)/, exclude: /(node_modules|bower_components|public)/,
loader: 'babel', loader: 'babel',
query: { query: {
presets: ['es2015', 'react'], presets: ['es2015', 'react'],
plugins: ['transform-runtime', 'transform-decorators-legacy', 'transform-class-properties'], plugins: ['transform-runtime', 'transform-decorators-legacy', 'transform-class-properties'],
} }
}, },
{ {
test: /\.(eot|svg|ttf|woff|woff2)$/, test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: 'file?name=fonts/[name].[ext]' loader: 'file?name=fonts/[name].[ext]'
}, },
{ {
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
exclude: /(node_modules|bower_components)/, exclude: /(node_modules|bower_components)/,
loader: "url?limit=10000&mimetype=image/svg+xml" loader: "url?limit=10000&mimetype=image/svg+xml"
}, },
{ {
test: /\.gif/, test: /\.gif/,
exclude: /(node_modules|bower_components)/, exclude: /(node_modules|bower_components)/,
loader: "url-loader?limit=10000&mimetype=image/gif" loader: "url-loader?limit=10000&mimetype=image/gif"
}, },
{ {
test: /\.jpg/, test: /\.jpg/,
exclude: /(node_modules|bower_components)/, exclude: /(node_modules|bower_components)/,
loader: "url-loader?limit=10000&mimetype=image/jpg" loader: "url-loader?limit=10000&mimetype=image/jpg"
}, },
{ {
test: /\.png/, test: /\.png/,
exclude: /(node_modules|bower_components)/, exclude: /(node_modules|bower_components)/,
loader: "url-loader?limit=10000&mimetype=image/png" loader: "url-loader?limit=10000&mimetype=image/png"
}, },
{ {
test: /\.json$/, test: /\.json$/,
loader: 'json-loader' loader: 'json-loader'
}, },
{ {
test: /\.js$/, test: /\.js$/,
include: '/node_modules/mapbox-gl-shaders/index.js', include: '/node_modules/mapbox-gl-shaders/index.js',
loader: 'transform/cacheable?brfs' loader: 'transform/cacheable?brfs'
} }
]; ];