Splitting out dev and prod webpack configs and updating some packages

This commit is contained in:
Alex Hunt 2018-04-25 18:58:58 -04:00
parent 335c5fdf47
commit bfabe75e97
7 changed files with 67 additions and 24 deletions

1
.gitignore vendored
View File

@ -5,6 +5,7 @@
/include
/icon
/node_modules
.pytest_cache/
*.pyc
pip-selfcheck.json
*.sublime-project

View File

@ -4,17 +4,18 @@
"description": "Reader and Editor for Hypertext",
"main": "app.js",
"scripts": {
"build": "webpack --config webpack.config.js",
"watch": "webpack --config webpack.config.js --watch",
"build": "webpack --config webpack.prod.js --mode=production",
"watch": "webpack --config webpack.dev.js --watch --mode=development",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Alex Hunt",
"license": "ISC",
"dependencies": {
"bootstrap": "^4.0.0-beta.2",
"bootstrap": "^4.1.0",
"draft-js": "^0.10.4",
"draft-js-export-html": "^1.2.0",
"draft-js-import-html": "^1.2.1",
"file-loader": "^1.1.11",
"font-awesome": "^4.7.0",
"object-assign": "^4.1.1",
"popper.js": "^1.12.6",
@ -40,7 +41,10 @@
"sass-loader": "^6.0.6",
"style-loader": "^0.19.0",
"sync-exec": "^0.6.2",
"webpack": "^3.8.1",
"webpack-bundle-size-analyzer": "^2.7.0"
"webpack": "^4.6.0",
"webpack-bundle-analyzer": "^2.11.1",
"webpack-bundle-size-analyzer": "^2.7.0",
"webpack-cli": "^2.0.15",
"webpack-merge": "^4.1.2"
}
}

View File

@ -13,7 +13,10 @@ const Navbar = () =>
</li>
<li className='nav-item'>
<a className='nav-link' href='/notes'>Notes</a>
</li>
</li>
<li className='nav-item'>
<a className='nav-link' href='/search'>Search</a>
</li>
</ul>
</div>
</nav>

View File

@ -39,7 +39,7 @@
}
#editor_content div {
overflow: scroll;
// overflow: scroll;
}
#editor_topbar button img {

View File

@ -28,26 +28,18 @@ module.exports = {
rootAssetPath + 'stylesheets/' + 'search.scss'
]
},
output: {
publicPath: "/static/js/",
filename: '[name].[hash].js',
path: path.resolve(__dirname, 'static/js/')
},
watch: true,
watchOptions: {
poll: true,
ignored: [
/node_modules/,
/DS_Store/
]
},
// output: {
// publicPath: "/static/js/",
// filename: '[name].[hash].js',
// path: path.resolve(__dirname, 'static/js/')
// },
module : {
rules: [
{
test: /\.(js)$/,
exclude: [
/node_modules/,
/DS_Store/
/\.DS_Store/
],
use: {
loader: 'babel-loader',
@ -66,7 +58,7 @@ module.exports = {
test: /\.(scss)$/,
exclude: [
/node_modules/,
/DS_Store/
/\.DS_Store/
],
use: [{
loader: 'style-loader',
@ -92,8 +84,6 @@ module.exports = {
}
]},
plugins: [
// TODO: Dev / Prod Config
// new webpack.optimize.UglifyJsPlugin(),
new ManifestRevisionPlugin(path.join('static/', 'manifest.json'), {
rootAssetPath: rootAssetPath
}),

21
webpack.dev.js Normal file
View File

@ -0,0 +1,21 @@
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const path = require('path')
module.exports = merge(common, {
output: {
publicPath: "/static/js/",
filename: '[name].[hash].js',
path: path.resolve(__dirname, 'static/js/')
},
// devServer: {
// contentBase: '.',
// hot: true
// },
watch: true,
watchOptions: {
poll: true,
ignored: /node_modules/
},
// new webpack.optimize.UglifyJsPlugin(),
});

24
webpack.prod.js Normal file
View File

@ -0,0 +1,24 @@
const webpack = require('webpack');
const merge = require('webpack-merge');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const common = require('./webpack.common.js');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const path = require('path')
module.exports = merge(common, {
output: {
publicPath: "/dist/js/",
filename: '[name].js',
path: path.resolve(__dirname, 'dist/js/')
},
optimization: {
minimize: true
},
plugins: [
new UglifyJSPlugin(),
new BundleAnalyzerPlugin,
new webpack.LoaderOptionsPlugin({
minimize: true,
})
]
});