Fix eslint errors and switch to babel-preset-env

master
Steven Loria 7 years ago
parent 000a2d91fc
commit 94fd865d78
No known key found for this signature in database
GPG Key ID: 631262B829DDB506
  1. 2
      {{cookiecutter.app_name}}/README.rst
  2. 2
      {{cookiecutter.app_name}}/package.json
  3. 44
      {{cookiecutter.app_name}}/webpack.config.js

@ -28,7 +28,7 @@ You will see a pretty welcome screen.
In general, before running shell commands, set the ``FLASK_APP`` and In general, before running shell commands, set the ``FLASK_APP`` and
``FLASK_DEBUG`` environment variables :: ``FLASK_DEBUG`` environment variables ::
export FLASK_APP=/path/to/autoapp.py export FLASK_APP=autoapp.py
export FLASK_DEBUG=1 export FLASK_DEBUG=1
Once you have installed your DBMS, run the following to create your app's Once you have installed your DBMS, run the following to create your app's

@ -28,7 +28,7 @@
"babel-core": "^6.25.0", "babel-core": "^6.25.0",
"babel-eslint": "^7.2.3", "babel-eslint": "^7.2.3",
"babel-loader": "^7.0.0", "babel-loader": "^7.0.0",
"babel-preset-es2015": "^6.24.1", "babel-preset-env": "^1.6.0",
"concurrently": "^3.5.0", "concurrently": "^3.5.0",
"css-loader": "^0.28.4", "css-loader": "^0.28.4",
"eslint": "^3.19.0", "eslint": "^3.19.0",

@ -1,3 +1,4 @@
const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
/* /*
@ -12,7 +13,7 @@ const debug = (process.env.NODE_ENV !== 'production');
// Development asset host (webpack dev server) // Development asset host (webpack dev server)
const publicHost = debug ? 'http://localhost:2992' : ''; const publicHost = debug ? 'http://localhost:2992' : '';
const rootAssetPath = './assets/'; const rootAssetPath = path.join(__dirname, 'assets');
module.exports = { module.exports = {
// configuration // configuration
@ -20,49 +21,48 @@ module.exports = {
entry: { entry: {
main_js: './assets/js/main', main_js: './assets/js/main',
main_css: [ main_css: [
'./node_modules/font-awesome/css/font-awesome.css', path.join(__dirname, 'node_modules', 'font-awesome', 'css', 'font-awesome.css'),
'./node_modules/bootstrap/dist/css/bootstrap.css', path.join(__dirname, 'node_modules', 'bootstrap', 'dist', 'css', 'bootstrap.css'),
'./assets/css/style.css' path.join(__dirname, 'assets', 'css', 'style.css'),
] ],
}, },
output: { output: {
path: __dirname + '/{{cookiecutter.app_name}}/static/build', path: path.join(__dirname, '{{cookiecutter.app_name}}', 'static', 'build'),
publicPath: publicHost + '/static/build/', publicPath: `${publicHost}/static/build/`,
filename: '[name].[hash].js', filename: '[name].[hash].js',
chunkFilename: '[id].[hash].js' chunkFilename: '[id].[hash].js',
}, },
resolve: { resolve: {
extensions: ['.js', '.jsx', '.css'] extensions: ['.js', '.jsx', '.css'],
}, },
devtool: debug ? 'inline-sourcemap' : 'source-map', devtool: 'source-map',
devServer: { devServer: {
headers: { 'Access-Control-Allow-Origin': '*' } headers: { 'Access-Control-Allow-Origin': '*' },
}, },
module: { module: {
loaders: [ loaders: [
{ test: /\.html$/, loader: 'raw-loader' }, { test: /\.html$/, loader: 'raw-loader' },
{ test: /\.less$/, loader: ExtractTextPlugin.extract({fallback: 'style-loader', use: 'css-loader!less-loader' }) }, { test: /\.less$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader!less-loader' }) },
{ test: /\.css$/, loader: ExtractTextPlugin.extract({fallback: 'style-loader', use: 'css-loader' }) }, { test: /\.css$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' }) },
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff' }, { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff' },
{ test: /\.(ttf|eot|svg|png|jpe?g|gif|ico)(\?.*)?$/i, { test: /\.(ttf|eot|svg|png|jpe?g|gif|ico)(\?.*)?$/i,
loader: 'file-loader?context=' + rootAssetPath + '&name=[path][name].[hash].[ext]' }, loader: `file-loader?context=${rootAssetPath}&name=[path][name].[hash].[ext]` },
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader', query: { presets: ['es2015'], cacheDirectory: true } }, { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader', query: { presets: ['env'], cacheDirectory: true } },
] ],
}, },
plugins: [ plugins: [
new ExtractTextPlugin('[name].[hash].css'), new ExtractTextPlugin('[name].[hash].css'),
new webpack.ProvidePlugin({ $: 'jquery', new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }),
jQuery: 'jquery' }), new ManifestRevisionPlugin(path.join(__dirname, '{{cookiecutter.app_name}}', 'webpack', 'manifest.json'), {
new ManifestRevisionPlugin(__dirname + '/{{cookiecutter.app_name}}/webpack/manifest.json', {
rootAssetPath, rootAssetPath,
ignorePaths: ['/js', '/css'] ignorePaths: ['/js', '/css'],
}), }),
].concat(debug ? [] : [ ].concat(debug ? [] : [
// production webpack plugins go here // production webpack plugins go here
new webpack.DefinePlugin({ new webpack.DefinePlugin({
'process.env': { 'process.env': {
'NODE_ENV': JSON.stringify('production') NODE_ENV: JSON.stringify('production'),
} }
}), }),
]) ]),
}; };

Loading…
Cancel
Save