feat(serve): Add npm run serve to expose js and css locally
This commit is contained in:
parent
be259f486c
commit
31e5d139d5
3 changed files with 58 additions and 0 deletions
|
|
@ -6,6 +6,7 @@
|
|||
"scripts": {
|
||||
"dev": "./scripts/dev",
|
||||
"dev:docs": "./scripts/dev-docs",
|
||||
"serve": "./scripts/serve",
|
||||
"shrinkwrap": "npm-shrinkwrap --dev",
|
||||
"doctoc": "doctoc --maxlevel 3 README.md CONTRIBUTING.md",
|
||||
"build": "./scripts/build",
|
||||
|
|
|
|||
17
scripts/serve
Executable file
17
scripts/serve
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env bash
|
||||
# Will expose the build version on:
|
||||
# - http://0.0.0.0:8080/docsearch.css
|
||||
# - http://0.0.0.0:8080/docsearch.js
|
||||
|
||||
npm run build:css
|
||||
|
||||
# /bundle.js in memory
|
||||
webpack-dev-server \
|
||||
--config webpack.serve.config.babel.js \
|
||||
--hot \
|
||||
--inline \
|
||||
--no-info & \
|
||||
# rebuild docsearch.css and docsearch.min.css
|
||||
onchange './src/styles/*.scss' -- npm run build:css & \
|
||||
|
||||
wait
|
||||
40
webpack.serve.config.babel.js
Normal file
40
webpack.serve.config.babel.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import webpack from 'webpack';
|
||||
import {join} from 'path';
|
||||
|
||||
export default {
|
||||
entry: './index.js',
|
||||
devtool: 'source-map',
|
||||
output: {
|
||||
path: './dist/cdn',
|
||||
filename: 'docsearch.js',
|
||||
library: 'docsearch',
|
||||
libraryTarget: 'umd'
|
||||
},
|
||||
module: {
|
||||
loaders: [{
|
||||
test: /\.js$/, exclude: /node_modules/, loader: 'babel'
|
||||
}]
|
||||
},
|
||||
devServer: {
|
||||
contentBase: 'dist/cdn',
|
||||
host: '0.0.0.0',
|
||||
compress: true
|
||||
},
|
||||
// when module not found, find locally first
|
||||
// helps fixing the npm link not working with webpack
|
||||
// http://stackoverflow.com/a/33722844/147079
|
||||
resolve: {
|
||||
fallback: [join(__dirname, '..', 'node_modules')]
|
||||
},
|
||||
// same issue, for loaders like babel
|
||||
resolveLoader: {
|
||||
fallback: [join(__dirname, '..', 'node_modules')]
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': {
|
||||
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
|
||||
}
|
||||
})
|
||||
]
|
||||
};
|
||||
Loading…
Reference in a new issue