feat(build-chain): set up and updated deps
This commit is contained in:
61
config/webpack.base.js
Normal file
61
config/webpack.base.js
Normal file
@@ -0,0 +1,61 @@
|
||||
const webpack = require("webpack");
|
||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||
const CopyPlugin = require('copy-webpack-plugin');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
const path = require("path");
|
||||
|
||||
const config = {
|
||||
entry: {
|
||||
main: ["./src/js/index.js"],
|
||||
},
|
||||
output: {
|
||||
path: path.join(__dirname, "..", "public"),
|
||||
filename: "[name]-[hash].js"
|
||||
},
|
||||
resolve: {
|
||||
extensions: ["*", ".json", ".js"]
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.(js)$/,
|
||||
exclude: /node_modules/,
|
||||
loader: "babel-loader",
|
||||
options: {
|
||||
compact: true
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: ['style-loader', 'css-loader']
|
||||
},
|
||||
{
|
||||
test: /\.(png|jpe?g|gif)$/i,
|
||||
use: [
|
||||
{
|
||||
loader: 'file-loader',
|
||||
},
|
||||
],
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new CleanWebpackPlugin(),
|
||||
new webpack.ProvidePlugin({
|
||||
$: 'jquery',
|
||||
jQuery: 'jquery',
|
||||
"window.jQuery": "jquery",
|
||||
"window.$": "jquery",
|
||||
}),
|
||||
new CopyPlugin([
|
||||
{ from: 'assets', to: '' },
|
||||
]),
|
||||
new HtmlWebpackPlugin({
|
||||
template: 'src/index.html',
|
||||
minify: false,
|
||||
inject: true
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
module.exports = config;
|
||||
11
config/webpack.build.js
Normal file
11
config/webpack.build.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const merge = require("webpack-merge");
|
||||
const baseConfig = require("./webpack.base");
|
||||
|
||||
module.exports = merge(baseConfig, {
|
||||
mode: "production",
|
||||
optimization: {
|
||||
minimize: true,
|
||||
nodeEnv: "production",
|
||||
},
|
||||
devtool: false
|
||||
});
|
||||
18
config/webpack.dev.js
Normal file
18
config/webpack.dev.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const merge = require("webpack-merge");
|
||||
const baseConfig = require("./webpack.base");
|
||||
const webpack = require("webpack");
|
||||
|
||||
const devConfig = merge(baseConfig, {
|
||||
mode: "development",
|
||||
devtool: "eval-source-map",
|
||||
optimization: {
|
||||
minimize: false,
|
||||
},
|
||||
plugins: [
|
||||
new webpack.HotModuleReplacementPlugin(),
|
||||
new webpack.NamedModulesPlugin(),
|
||||
new webpack.NoEmitOnErrorsPlugin(), // don't reload if there is an error
|
||||
].concat(baseConfig.plugins),
|
||||
});
|
||||
|
||||
module.exports = devConfig;
|
||||
Reference in New Issue
Block a user