aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/config/webpack
diff options
context:
space:
mode:
authorJérémy Benoist <j0k3r@users.noreply.github.com>2017-10-23 11:09:17 +0200
committerGitHub <noreply@github.com>2017-10-23 11:09:17 +0200
commit1953a872932a63792293b4aec087880265ba89f7 (patch)
treefd16599e737fcdaf193c933ef3ec4a4ee248b117 /app/config/webpack
parentd83d25dadec2c38460a32d96f5d2903426fec9d3 (diff)
parent702f2d67d60ca963492b90dad74cb5f8dcc84e51 (diff)
downloadwallabag-1953a872932a63792293b4aec087880265ba89f7.tar.gz
wallabag-1953a872932a63792293b4aec087880265ba89f7.tar.zst
wallabag-1953a872932a63792293b4aec087880265ba89f7.zip
Merge pull request #3011 from wallabag/2.3
wallabag 2.3.0
Diffstat (limited to 'app/config/webpack')
-rw-r--r--app/config/webpack/common.js40
-rw-r--r--app/config/webpack/dev.js61
-rw-r--r--app/config/webpack/prod.js111
3 files changed, 212 insertions, 0 deletions
diff --git a/app/config/webpack/common.js b/app/config/webpack/common.js
new file mode 100644
index 00000000..c497689a
--- /dev/null
+++ b/app/config/webpack/common.js
@@ -0,0 +1,40 @@
1const path = require('path');
2const webpack = require('webpack');
3const StyleLintPlugin = require('stylelint-webpack-plugin');
4
5const rootDir = path.resolve(__dirname, '../../../');
6
7module.exports = function () {
8 return {
9 entry: {
10 material: path.join(rootDir, './app/Resources/static/themes/material/index.js'),
11 baggy: path.join(rootDir, './app/Resources/static/themes/baggy/index.js'),
12 public: path.join(rootDir, './app/Resources/static/themes/_global/share.js'),
13 },
14 output: {
15 filename: '[name].js',
16 path: path.resolve(rootDir, 'web/bundles/wallabagcore'),
17 publicPath: '/bundles/wallabagcore/',
18 },
19 plugins: [
20 new webpack.ProvidePlugin({
21 $: 'jquery',
22 jQuery: 'jquery',
23 'window.$': 'jquery',
24 'window.jQuery': 'jquery',
25 }),
26 new StyleLintPlugin({
27 configFile: '.stylelintrc',
28 failOnError: false,
29 quiet: false,
30 context: 'app/Resources/static/themes',
31 files: '**/*.scss',
32 }),
33 ],
34 resolve: {
35 alias: {
36 jquery: path.join(rootDir, 'node_modules/jquery/dist/jquery.js'),
37 },
38 },
39 };
40};
diff --git a/app/config/webpack/dev.js b/app/config/webpack/dev.js
new file mode 100644
index 00000000..97abc5eb
--- /dev/null
+++ b/app/config/webpack/dev.js
@@ -0,0 +1,61 @@
1const webpackMerge = require('webpack-merge');
2const webpack = require('webpack');
3const commonConfig = require('./common.js');
4
5module.exports = function () {
6 return webpackMerge(commonConfig(), {
7 devtool: 'eval-source-map',
8 output: {
9 filename: '[name].dev.js',
10 },
11
12 devServer: {
13 hot: true,
14 // enable HMR on the server
15
16 contentBase: './web',
17 // match the output path
18 },
19 plugins: [
20 new webpack.HotModuleReplacementPlugin(),
21 ],
22 module: {
23 rules: [
24 {
25 enforce: 'pre',
26 test: /\.js$/,
27 loader: 'eslint-loader',
28 exclude: /node_modules/,
29 },
30 {
31 test: /\.js$/,
32 exclude: /(node_modules)/,
33 use: {
34 loader: 'babel-loader',
35 options: {
36 presets: ['env'],
37 },
38 },
39 },
40 {
41 test: /\.(s)?css$/,
42 use: [
43 'style-loader',
44 {
45 loader: 'css-loader',
46 options: {
47 importLoaders: 1,
48 },
49 },
50 'postcss-loader',
51 'sass-loader',
52 ],
53 },
54 {
55 test: /\.(jpg|png|gif|svg|ico|eot|ttf|woff|woff2)$/,
56 use: 'url-loader',
57 },
58 ],
59 },
60 });
61};
diff --git a/app/config/webpack/prod.js b/app/config/webpack/prod.js
new file mode 100644
index 00000000..17b8c384
--- /dev/null
+++ b/app/config/webpack/prod.js
@@ -0,0 +1,111 @@
1const webpack = require('webpack');
2const webpackMerge = require('webpack-merge');
3const ExtractTextPlugin = require('extract-text-webpack-plugin');
4const ManifestPlugin = require('webpack-manifest-plugin');
5
6const commonConfig = require('./common.js');
7
8module.exports = function () {
9 return webpackMerge(commonConfig(), {
10 output: {
11 filename: '[name].js',
12 },
13 devtool: 'source-map',
14 plugins: [
15 new webpack.DefinePlugin({
16 'process.env': {
17 'NODE_ENV': JSON.stringify('production'),
18 },
19 }),
20 new webpack.optimize.UglifyJsPlugin({
21 beautify: false,
22 mangle: {
23 screw_ie8: true,
24 keep_fnames: true,
25 },
26 compress: {
27 screw_ie8: true,
28 warnings: false,
29 },
30 comments: false,
31 }),
32 new ExtractTextPlugin('[name].css'),
33 new ManifestPlugin({
34 fileName: 'manifest.json',
35 }),
36 ],
37 module: {
38 rules: [
39 {
40 enforce: 'pre',
41 test: /\.js$/,
42 loader: 'eslint-loader',
43 exclude: /node_modules/,
44 },
45 {
46 test: /\.js$/,
47 exclude: /(node_modules)/,
48 use: {
49 loader: 'babel-loader',
50 options: {
51 presets: ['env'],
52 },
53 },
54 },
55 {
56 test: /\.(s)?css$/,
57 use: ExtractTextPlugin.extract({
58 fallback: 'style-loader',
59 use: [
60 {
61 loader: 'css-loader',
62 options: {
63 importLoaders: 1,
64 minimize: {
65 discardComments: {
66 removeAll: true,
67 },
68 core: true,
69 minifyFontValues: true,
70 },
71 },
72 },
73 'postcss-loader',
74 'sass-loader',
75 ],
76 }),
77 },
78 {
79 test: /\.(jpg|png|gif|svg|ico)$/,
80 include: /node_modules/,
81 use: {
82 loader: 'file-loader',
83 options: {
84 name: 'img/[name].[ext]',
85 },
86 },
87 },
88 {
89 test: /\.(jpg|png|gif|svg|ico)$/,
90 exclude: /node_modules/,
91 use: {
92 loader: 'file-loader',
93 options: {
94 context: 'app/Resources/static',
95 name: '[path][name].[ext]',
96 },
97 },
98 },
99 {
100 test: /\.(eot|ttf|woff|woff2)$/,
101 use: {
102 loader: 'file-loader',
103 options: {
104 name: 'fonts/[name].[ext]',
105 },
106 },
107 },
108 ],
109 },
110 });
111};