Browse Source

Used webpack-merge for webpack configs

update-deps
Alex Mikhalev 8 years ago
parent
commit
e8705f0224
  1. 3
      package.json
  2. 33
      webpack/base.config.js
  3. 23
      webpack/dev.config.js
  4. 24
      webpack/prod.config.js
  5. 6
      yarn.lock

3
package.json

@ -40,7 +40,8 @@
"react-dom": "^15.5.4", "react-dom": "^15.5.4",
"react-fontawesome": "^1.6.1", "react-fontawesome": "^1.6.1",
"semantic-ui-css": "^2.2.10", "semantic-ui-css": "^2.2.10",
"semantic-ui-react": "^0.68.5" "semantic-ui-react": "^0.68.5",
"webpack-merge": "^4.1.0"
}, },
"devDependencies": { "devDependencies": {
"@types/webpack-env": "^1.13.0", "@types/webpack-env": "^1.13.0",

33
webpack/base.config.js

@ -0,0 +1,33 @@
const path = require("path");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
devtool: "inline-source-map",
output: {
path: path.resolve(__dirname, "..", "build"),
filename: "bundle.js"
},
resolve: {
extensions: [".ts", ".tsx", ".js"],
alias: {
app: path.resolve(__dirname, "..", "app")
}
},
module: {
rules: [
{ test: /\.css$/, loader: "style-loader!css-loader" },
{ test: /\.(ttf|eot|svg|woff(2)?|png|jpg)(\?[a-z0-9=&.]+)?$/, loader: "file-loader" }
]
},
plugins: [
new HtmlWebpackPlugin({
template: "./app/index.html"
}),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin()
],
devServer: {
hot: true
}
};

23
webpack/dev.config.js

@ -1,8 +1,8 @@
const path = require("path");
const webpack = require("webpack"); const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin"); const webpackMerge = require("webpack-merge");
const base = require("./base.config");
module.exports = { module.exports = webpackMerge.smart(base, {
entry: [ entry: [
"react-hot-loader/patch", "react-hot-loader/patch",
"webpack-dev-server/client?http://localhost:8080", "webpack-dev-server/client?http://localhost:8080",
@ -10,31 +10,16 @@ module.exports = {
"./app/script/index.tsx" "./app/script/index.tsx"
], ],
devtool: "inline-source-map", devtool: "inline-source-map",
output: {
path: path.resolve(__dirname, "../build"),
filename: "bundle.js"
},
resolve: {
extensions: [".ts", ".tsx", ".js"],
alias: {
app: path.resolve("./app")
}
},
module: { module: {
rules: [ rules: [
{ test: /\.tsx?$/, loaders: ["react-hot-loader/webpack", "awesome-typescript-loader"] }, { test: /\.tsx?$/, loaders: ["react-hot-loader/webpack", "awesome-typescript-loader"] },
{ test: /\.css$/, loader: "style-loader!css-loader" },
{ test: /\.(ttf|eot|svg|woff(2)?|png|jpg)(\?[a-z0-9=&.]+)?$/, loader: "file-loader" }
] ]
}, },
plugins: [ plugins: [
new HtmlWebpackPlugin({
template: "./app/index.html"
}),
new webpack.NamedModulesPlugin(), new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin() new webpack.HotModuleReplacementPlugin()
], ],
devServer: { devServer: {
hot: true hot: true
} }
}; });

24
webpack/prod.config.js

@ -1,32 +1,16 @@
const path = require("path"); const webpackMerge = require("webpack-merge");
const webpack = require("webpack"); const base = require("./base.config");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = { module.exports = webpackMerge.smart(base, {
entry: [ entry: [
"./app/script/index.tsx" "./app/script/index.tsx"
], ],
devtool: "none", devtool: "none",
output: {
path: path.resolve(__dirname, "../dist"),
filename: "bundle.js"
},
resolve: {
extensions: [".ts", ".tsx", ".js"],
alias: {
app: path.resolve("./app")
}
},
module: { module: {
rules: [ rules: [
{ test: /\.tsx?$/, loader: "awesome-typescript-loader" }, { test: /\.tsx?$/, loader: "awesome-typescript-loader" },
{ test: /\.css$/, loader: "style-loader!css-loader" },
{ test: /\.(ttf|eot|svg|woff(2)?|png|jpg)(\?[a-z0-9=&.]+)?$/, loader: "file-loader" }
] ]
}, },
plugins: [ plugins: [
new HtmlWebpackPlugin({
template: "./app/index.html"
})
] ]
}; });

6
yarn.lock

@ -3523,6 +3523,12 @@ webpack-dev-server@^2.4.4:
webpack-dev-middleware "^1.10.2" webpack-dev-middleware "^1.10.2"
yargs "^6.0.0" yargs "^6.0.0"
webpack-merge@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-4.1.0.tgz#6ad72223b3e0b837e531e4597c199f909361511e"
dependencies:
lodash "^4.17.4"
webpack-sources@^0.2.3: webpack-sources@^0.2.3:
version "0.2.3" version "0.2.3"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-0.2.3.tgz#17c62bfaf13c707f9d02c479e0dcdde8380697fb" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-0.2.3.tgz#17c62bfaf13c707f9d02c479e0dcdde8380697fb"

Loading…
Cancel
Save