mirror of
https://github.com/fspc/workstand.git
synced 2025-02-23 09:13:23 -05:00
Enable HMR.
This commit is contained in:
parent
dfa89f1900
commit
ce64d08619
16
bikeshop_project/server.js
Normal file
16
bikeshop_project/server.js
Normal file
@ -0,0 +1,16 @@
|
||||
var webpack = require('webpack')
|
||||
var WebpackDevServer = require('webpack-dev-server')
|
||||
var config = require('./webpack.dev.config')
|
||||
|
||||
new WebpackDevServer(webpack(config), {
|
||||
publicPath: config.output.publicPath,
|
||||
hot: true,
|
||||
inline: true,
|
||||
historyApiFallback: true
|
||||
}).listen(3000, '0.0.0.0', function (err, result) {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
}
|
||||
|
||||
console.log('Listening at 0.0.0.0:3000')
|
||||
})
|
36
bikeshop_project/webpack.base.config.js
Normal file
36
bikeshop_project/webpack.base.config.js
Normal file
@ -0,0 +1,36 @@
|
||||
var path = require("path")
|
||||
var webpack = require('webpack')
|
||||
var BundleTracker = require('webpack-bundle-tracker')
|
||||
|
||||
const autoprefixer = require('autoprefixer');
|
||||
|
||||
module.exports = {
|
||||
context: __dirname,
|
||||
|
||||
entry: './assets/js/index',
|
||||
|
||||
output: {
|
||||
path: path.resolve('./assets/bundles/'),
|
||||
filename: "[name]-[hash].js"
|
||||
},
|
||||
|
||||
plugins: [
|
||||
|
||||
], // add all common plugins here
|
||||
|
||||
module: {
|
||||
loaders: [
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
resolve: {
|
||||
modulesDirectories: [
|
||||
'node_modules',
|
||||
'bower_components',
|
||||
path.resolve(__dirname, './node_modules')
|
||||
],
|
||||
extensions: ['', '.js', '.jsx', '.scss']
|
||||
},
|
||||
postcss: [autoprefixer]
|
||||
}
|
42
bikeshop_project/webpack.dev.config.js
Normal file
42
bikeshop_project/webpack.dev.config.js
Normal file
@ -0,0 +1,42 @@
|
||||
var path = require("path")
|
||||
var webpack = require('webpack')
|
||||
var BundleTracker = require('webpack-bundle-tracker')
|
||||
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||
|
||||
var config = require('./webpack.base.config.js')
|
||||
|
||||
// Use webpack dev server
|
||||
config.entry = [
|
||||
'webpack-dev-server/client?http://localhost:3000',
|
||||
'webpack/hot/only-dev-server',
|
||||
'./assets/js/index'
|
||||
]
|
||||
|
||||
// override django's STATIC_URL for webpack bundles
|
||||
config.output.publicPath = 'http://localhost:3000/assets/bundles/'
|
||||
|
||||
// Add HotModuleReplacementPlugin and BundleTracker plugins
|
||||
config.plugins = config.plugins.concat([
|
||||
new webpack.HotModuleReplacementPlugin(),
|
||||
new webpack.NoErrorsPlugin(),
|
||||
new BundleTracker({filename: './webpack-stats.json'}),
|
||||
new ExtractTextPlugin('react-toolbox.css', {allChunks: true}),
|
||||
])
|
||||
|
||||
// Add a loader for JSX files with react-hot enabled
|
||||
config.module.loaders.push(
|
||||
{
|
||||
test: /\.jsx?$/,
|
||||
exclude: /node_modules/,
|
||||
loader: 'babel-loader',
|
||||
query: {
|
||||
presets: ['es2015', 'stage-0', 'react']
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /(\.scss|\.css)$/,
|
||||
loader: ExtractTextPlugin.extract('style', 'css?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!sass?sourceMap!toolbox')
|
||||
}
|
||||
)
|
||||
|
||||
module.exports = config
|
Loading…
x
Reference in New Issue
Block a user