Skip to content

Commit a8e47d8

Browse files
author
anthinkingcoder
committed
add extracss webpack.config.js
1 parent 9edd257 commit a8e47d8

5 files changed

+234
-151
lines changed

build/webpack.base.config.js

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
var path = require('path');
2-
var webpack = require('webpack');
3-
const ExtractTextPlugin = require('extract-text-webpack-plugin')
4-
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
1+
var path = require('path')
2+
var webpack = require('webpack')
53
const VueLoaderPlugin = require('vue-loader/lib/plugin')
64
function resolve (dir) {
7-
return path.join(__dirname, '..', dir);
5+
return path.join(__dirname, '..', dir)
86
}
97
function assetsPath (_path) {
108
return path.posix.join('static', _path)
@@ -51,32 +49,6 @@ module.exports = {
5149
],
5250
exclude: /node_modules/,
5351
},
54-
{
55-
test: /\.scss$/,
56-
use: [
57-
{
58-
loader: 'style-loader',
59-
options: {
60-
sourceMap: true,
61-
},
62-
},
63-
{
64-
loader: 'css-loader',
65-
options: {
66-
sourceMap: true,
67-
},
68-
},
69-
{
70-
loader: 'postcss-loader',
71-
},
72-
{
73-
loader: 'sass-loader',
74-
options: {
75-
sourceMap: true,
76-
},
77-
}
78-
],
79-
},
8052
{
8153
test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
8254
use: 'url-loader?limit=8192'
@@ -85,14 +57,6 @@ module.exports = {
8557
test: /\.(html|tpl)$/,
8658
use: 'html-loader'
8759
}
88-
// {
89-
// test: /\.scss$/,
90-
// use: ExtractTextPlugin.extract({
91-
// fallback: 'style-loader',
92-
// use: ['css-loader', 'autoprefixer-loader', 'sass-loader']
93-
// })
94-
// },
95-
9660
],
9761
},
9862
resolve: {
@@ -109,15 +73,6 @@ module.exports = {
10973
NODE_ENV: '"production"'
11074
}
11175
}),
112-
// new UglifyJsPlugin({
113-
// parallel: true,
114-
// sourceMap: true,
115-
116-
// }),
11776
new webpack.optimize.OccurrenceOrderPlugin(),
118-
// new ExtractTextPlugin({
119-
// filename: 'simple-grid.css',
120-
// allChunks: false,
121-
// })
12277
]
12378
};

build/webpack.extracss.config.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const merge = require('webpack-merge')
2+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
3+
const webpackBaseConfig = require('./webpack.base.config.js')
4+
5+
module.exports = merge(webpackBaseConfig, {
6+
module: {
7+
rules: [
8+
{
9+
test: /\.scss$/,
10+
use: [
11+
{
12+
loader: MiniCssExtractPlugin.loader,
13+
options: {
14+
15+
}
16+
},
17+
"css-loader","postcss-loader","sass-loader"
18+
]
19+
},
20+
],
21+
},
22+
plugins: [
23+
new MiniCssExtractPlugin({
24+
// Options similar to the same options in webpackOptions.output
25+
// both options are optional
26+
filename: "simple-grid.css",
27+
chunkFilename: "[id].css"
28+
})
29+
]
30+
})

build/webpack.no.extracss.config.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const path = require('path');
2+
const webpack = require('webpack');
3+
const merge = require('webpack-merge');
4+
const webpackBaseConfig = require('./webpack.base.config.js');
5+
6+
7+
module.exports = merge(webpackBaseConfig, {
8+
module: {
9+
rules: [
10+
{
11+
test: /\.scss$/,
12+
use: [
13+
{
14+
loader: 'style-loader',
15+
options: {
16+
sourceMap: true,
17+
},
18+
},
19+
{
20+
loader: 'css-loader',
21+
options: {
22+
sourceMap: true,
23+
},
24+
},
25+
{
26+
loader: 'postcss-loader',
27+
},
28+
{
29+
loader: 'sass-loader',
30+
options: {
31+
sourceMap: true,
32+
},
33+
}
34+
],
35+
},
36+
],
37+
}
38+
})

0 commit comments

Comments
 (0)