mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-02 14:02:46 +02:00
Serve bundle from memory when devving
This commit is contained in:
parent
9a9e7f7b25
commit
a63fae8f5b
|
@ -5,8 +5,8 @@
|
|||
"main": "./public/assets/scripts/choices.min.js",
|
||||
"types": "./types/index.d.ts",
|
||||
"scripts": {
|
||||
"start": "npm run clear && NODE_ENV=development node server.js",
|
||||
"build": "npm run clear && npm run js:build && npm run css:build",
|
||||
"start": "NODE_ENV=development node server.js",
|
||||
"build": "npm run js:build && npm run css:build",
|
||||
"lint": "eslint assets/**/*.js",
|
||||
"coverage": "nyc npm run test",
|
||||
"test": "mocha --require ./config/test.js --compilers js:babel-core/register \"./src/**/**/**/**/*.test.js\"",
|
||||
|
@ -18,7 +18,6 @@
|
|||
"css:prefix": "postcss --use autoprefixer -b 'last 2 versions' public/assets/styles/*.css -d public/assets/styles",
|
||||
"css:min": "csso public/assets/styles/base.css public/assets/styles/base.min.css && csso public/assets/styles/choices.css public/assets/styles/choices.min.css",
|
||||
"js:build": "concurrently --prefix-colors yellow,green \"webpack --env.minimize --config webpack.config.prod.js\" \"webpack --config webpack.config.prod.js\"",
|
||||
"clear": "rm -rf public/assets/scripts",
|
||||
"version": "node version.js --current $npm_package_version --new $npm_config_newVersion",
|
||||
"postversion": "npm run js:build",
|
||||
"prepush": "npm run lint && npm run test"
|
||||
|
|
19
server.js
19
server.js
|
@ -2,12 +2,12 @@
|
|||
const express = require('express');
|
||||
const path = require('path');
|
||||
|
||||
const PORT = 3001;
|
||||
const DIST_DIR = path.join(__dirname, 'public');
|
||||
|
||||
const app = express();
|
||||
const port = 3001;
|
||||
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
const webpack = require('webpack');
|
||||
const webpackDevMiddleware = require('webpack-dev-middleware');
|
||||
const webpackHotMiddleware = require('webpack-hot-middleware');
|
||||
|
@ -17,21 +17,20 @@ if (process.env.NODE_ENV === 'development') {
|
|||
const compiler = webpack(config);
|
||||
|
||||
app.use(webpackDevMiddleware(compiler, {
|
||||
publicPath: config.output.publicPath,
|
||||
publicPath: '/assets/scripts/',
|
||||
stats: {
|
||||
colors: true,
|
||||
},
|
||||
}));
|
||||
|
||||
app.use(webpackHotMiddleware(compiler, {
|
||||
log: console.log,
|
||||
}));
|
||||
app.use(webpackHotMiddleware(compiler));
|
||||
}
|
||||
|
||||
app.listen(port, (err) => {
|
||||
app.use(express.static(DIST_DIR));
|
||||
app.listen(PORT, (err) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
console.log(`Listening at ${port} 👂`);
|
||||
console.log(`Listening at ${PORT} 👂`);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue