|
|
@ -6,9 +6,16 @@ const webpack = require('webpack'); |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); |
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); |
|
|
|
|
|
|
|
|
|
|
|
// take debug mode from the environment
|
|
|
|
const ProductionPlugins = [ |
|
|
|
const debug = (process.env.NODE_ENV !== 'production'); |
|
|
|
// production webpack plugins go here
|
|
|
|
|
|
|
|
new webpack.DefinePlugin({ |
|
|
|
|
|
|
|
"process.env": { |
|
|
|
|
|
|
|
NODE_ENV: JSON.stringify("production") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const debug = (process.env.NODE_ENV !== 'production'); |
|
|
|
const rootAssetPath = path.join(__dirname, 'assets'); |
|
|
|
const rootAssetPath = path.join(__dirname, 'assets'); |
|
|
|
|
|
|
|
|
|
|
|
module.exports = { |
|
|
|
module.exports = { |
|
|
@ -22,16 +29,21 @@ module.exports = { |
|
|
|
path.join(__dirname, 'assets', 'css', 'style.css'), |
|
|
|
path.join(__dirname, 'assets', 'css', 'style.css'), |
|
|
|
], |
|
|
|
], |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
mode: debug, |
|
|
|
output: { |
|
|
|
output: { |
|
|
|
|
|
|
|
chunkFilename: "[id].js", |
|
|
|
|
|
|
|
filename: "[name].bundle.js", |
|
|
|
path: path.join(__dirname, "{{cookiecutter.app_name}}", "static", "build"), |
|
|
|
path: path.join(__dirname, "{{cookiecutter.app_name}}", "static", "build"), |
|
|
|
publicPath: "/static/build/", |
|
|
|
publicPath: "/static/build/" |
|
|
|
filename: "[name].js", |
|
|
|
|
|
|
|
chunkFilename: "[id].js" |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
resolve: { |
|
|
|
resolve: { |
|
|
|
extensions: [".js", ".jsx", ".css"] |
|
|
|
extensions: [".js", ".jsx", ".css"] |
|
|
|
}, |
|
|
|
}, |
|
|
|
devtool: "source-map", |
|
|
|
devtool: debug ? "eval-source-map" : null, |
|
|
|
|
|
|
|
plugins: [ |
|
|
|
|
|
|
|
new MiniCssExtractPlugin({ filename: "[name].bundle.css" }), |
|
|
|
|
|
|
|
new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery" }) |
|
|
|
|
|
|
|
].concat(debug ? [] : ProductionPlugins), |
|
|
|
module: { |
|
|
|
module: { |
|
|
|
rules: [ |
|
|
|
rules: [ |
|
|
|
{ |
|
|
|
{ |
|
|
@ -66,20 +78,5 @@ module.exports = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader', query: { presets: ['env'], cacheDirectory: true } }, |
|
|
|
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader', query: { presets: ['env'], cacheDirectory: true } }, |
|
|
|
], |
|
|
|
], |
|
|
|
}, |
|
|
|
} |
|
|
|
plugins: [ |
|
|
|
|
|
|
|
new MiniCssExtractPlugin({ filename: "[name].css" }), |
|
|
|
|
|
|
|
new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery" }) |
|
|
|
|
|
|
|
].concat( |
|
|
|
|
|
|
|
debug |
|
|
|
|
|
|
|
? [] |
|
|
|
|
|
|
|
: [ |
|
|
|
|
|
|
|
// production webpack plugins go here
|
|
|
|
|
|
|
|
new webpack.DefinePlugin({ |
|
|
|
|
|
|
|
"process.env": { |
|
|
|
|
|
|
|
NODE_ENV: JSON.stringify("production") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|